Skip to main content

Scale ECS Services

Last updated on

The ECS Scale step lets you scale any ECS service running in a cluster — independent of your deployment execution. Instead of triggering a full deployment stage to adjust instance counts, you can add this step to any pipeline and target any service in any ECS cluster you have access to.

This is useful when you need to scale services that are not part of the current deployment. For example, you might want to scale down a background worker service before deploying a new version of your primary application, or scale up a dependent service after deployment completes.

note

Currently, this feature is behind the feature flag CDS_ECS_SCALE_STEP. Contact Harness Support to enable the feature. This step requires a minimum delegate version of 88503.

note

If you are new to Harness ECS support, go to ECS deployments.

Key capabilities

  • Scale any service in a cluster: Target any existing ECS service, not just the service being deployed in the current pipeline.
  • Flexible infrastructure configuration: Optionally override the AWS connector, region, and cluster at the step level. If omitted, the step inherits these from the stage's environment configuration.
  • Standalone utility step: Works in CD stages alongside other ECS deployment steps.

Configure the ECS Scale step

  1. In your pipeline, go to the Execution tab of your CD stage.
  2. Select Add Step, then choose ECS Scale from the step library.
  1. Configure the following fields:

Step parameters

FieldDescription
NameA name for the step.
TimeoutHow long Harness should wait for the step to complete before failing. Default is 10m.
Connector(Optional) Reference to an AWS connector. If not provided, the connector from the stage's environment infrastructure is used.
Region(Optional) The AWS region where the ECS cluster is running. Inherited from the environment if not specified.
Cluster(Optional) The ECS cluster name. Inherited from the environment if not specified.
ServiceThe name of the ECS service to scale. You can select from the list of services running in the target cluster.
Instance UnitChoose Count (absolute number of tasks) or Percentage (percentage of the service's current desired count).
InstancesThe target number or percentage of instances to scale to.
Skip Steady State CheckWhen enabled, Harness triggers the scale operation but does not wait for the service to reach a steady state. Default is false.
tip

When Connector, Region, or Cluster are left empty, the step picks up these values from the environment's infrastructure definition configured in the stage. Provide explicit values only when you need to target a service in a different cluster or AWS account.

YAML example

ECS Scale step YAML

The following YAML scales the my_backend_service to 4 instances in a specific cluster:

- step:
type: EcsScale
name: Scale Backend Service
identifier: ScaleBackendService
spec:
service: my_backend_service
instanceUnit: Count
instances: 4
connectorRef: my_aws_connector
region: us-east-1
cluster: my-ecs-cluster
timeout: 10m

Pipeline example

This pipeline shows a common use case: deploying a primary ECS service using a basic deployment strategy, then scaling a different backend service in a separate cluster after an approval gate. The ECS Scale step targets my_backend_service on my-ecs-cluster using its own AWS connector and region, independent of the infrastructure defined in the stage's environment.

This pattern is useful when a deployment to one service requires a dependent service to be scaled up (or down) as part of the same pipeline — without triggering a full redeployment of that dependent service.

Pipeline YAML with ECS Scale step
pipeline:
name: ecs_basic_with_scale
identifier: ecs_basic_with_scale
projectIdentifier: my_project
orgIdentifier: default
tags: {}
stages:
- stage:
name: ecs_deploy
identifier: ecs_deploy
description: ""
type: Deployment
spec:
deploymentType: ECS
service:
serviceRef: my_ecs_service
environment:
environmentRef: staging
deployToAll: false
infrastructureDefinitions:
- identifier: my_ecs_infra
execution:
steps:
- stepGroup:
name: Basic Deployment
identifier: basicDeployment
steps:
- step:
name: ECS Service Setup
identifier: EcsServiceSetup
type: EcsServiceSetup
timeout: 10m
spec:
resizeStrategy: ResizeNewFirst
- step:
name: ECS Upgrade Container
identifier: EcsUpgradeContainer
type: EcsUpgradeContainer
timeout: 10m
spec:
newServiceInstanceCount: 5
newServiceInstanceUnit: Count
downsizeOldServiceInstanceCount: 1
downsizeOldServiceInstanceUnit: Count
- step:
type: HarnessApproval
name: Approval Before Scale
identifier: ApprovalBeforeScale
spec:
approvalMessage: Please review and approve before scaling the backend service.
includePipelineExecutionHistory: true
isAutoRejectEnabled: false
approvers:
userGroups:
- account._account_all_users
minimumCount: 1
disallowPipelineExecutor: false
approverInputs: []
timeout: 1d
- step:
type: EcsScale
name: Scale Backend Service
identifier: ScaleBackendService
spec:
service: my_backend_service
instanceUnit: Count
instances: 4
connectorRef: my_aws_connector
region: us-east-1
cluster: my-ecs-cluster
timeout: 10m
rollbackSteps:
- step:
name: ECS Basic Rollback
identifier: EcsBasicRollback
type: EcsBasicRollback
timeout: 10m
spec: {}
tags: {}
failureStrategies:
- onFailure:
errors:
- AllErrors
action:
type: StageRollback

Advanced settings

In the Advanced tab, you can configure: