Skip to content
play

GitHub Action

AWS ECS Scale up/down

1.2.0 Latest version

AWS ECS Scale up/down

play

AWS ECS Scale up/down

Update the desired number of tasks for an ECS service

Installation

Copy and paste the following snippet into your .yml file.

              

- name: AWS ECS Scale up/down

uses: zachelrath/[email protected]

Learn more about this action in zachelrath/github-action-ecs-scale

Choose a version

github-action-ecs-scale

The purpose of this repository is to provide a GitHub Action to scale an ECS service's desired count up/down to a desired value.

What it does

  1. Uses the AWS SDK for JavaScript to update the specified ECS Service's desired count attribute to a given value.

General Usage

This Action expects that you have already configured AWS credentials in a prior step, e.g. using aws-actions/configure-aws-credentials. Please see that Action's documentation for more details.

jobs:
  ecs-scaledown:
    name: Scale down ECS Tasks
    runs-on: ubuntu-latest
    steps:
      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@v2
        with:
          role-to-assume: ${{ secrets.AWS_ECS_ROLE_ARN }}
          role-session-name: ecsscale
          aws-region: ${{ vars.AWS_REGION }}
      - name: Scale Web App to zero
        uses: zachelrath/[email protected]
        with:
          service: ${{ vars.ECS_WEB_APP_SERVICE_NAME }}
          cluster: ${{ vars.ECS_CLUSTER_NAME }}
          desired-count: 0
      - name: Scale Worker task to 1
        uses: zachelrath/[email protected]
        with:
          service: ${{ vars.ECS_WORKER_SERVICE_NAME }}
          cluster: ${{ vars.ECS_CLUSTER_NAME }}
          desired-count: 1