Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

Latest commit

 

History

History
74 lines (59 loc) · 2.71 KB

README.md

File metadata and controls

74 lines (59 loc) · 2.71 KB

ecs-scaledown

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

This action leverages the aws-actions/configure-aws-credentials action. Since GitHub Actions currently does not allow composite actions to call other actions, we chose to integrate the JavaScript code from existing aws-actions into this repository.

What it does

  1. Configure AWS credentials. Uses existing action: aws-actions/configure-aws-credentials
  2. Uses the AWS SDK for JavaScript to decrement the specified ECS Service's desired count attribute to 0.

Modifications made to existing AWS actions

No modifications made. the index.js and cleanup.js files from the configure-aws-credentials action were copied into src/main/configAwsCreds.js and src/cleanup/configAwsCreds.js.

Use Case and Usage

This action was developed as a way to scale down an ECS Service after the tasks no longer need to be run. Specifically, this is designed to work following a workflow using Self-Hosted GitHub Runners that are stood up by the trussworks/ecs-scaleup action.

General Usage

ecs-scaledown:
  name: Scale down ECS Service
  needs: [ecs-scaleup, ALL_OTHER_JOBS]
  runs-on: ubuntu-latest
  steps:
    - name: ecs-scaledown
      uses: trussworks/ecs-scaledown
      with:
        aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
        aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
        aws-region: "us-east-1"
        service: github-actions-runner
        cluster: github-runner

Using with Self-Hosted GitHub Runners

If you are using this action to deprovision self-hosted GitHub runners from the cmsgov/github-actions-runner-aws repository, the service, and cluster can all be specified by the single hash generated by the module, and you can replace those variables with a single variable called repository-hash, like so:

ecs-scaledown:
  name: Scale down ECS Service
  needs: [ecs-scaleup, ALL_OTHER_JOBS]
  runs-on: ubuntu-latest
  steps:
    - name: ecs-scaledown
      uses: trussworks/ecs-scaledown
      with:
        aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
        aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
        aws-region: "us-east-1"
        repository-hash: aa50c18a-3141-506e-a0da-b96b2e12048e

NOTE: When using this to deprovision Self-Hosted GitHub runners, you must populate the needs argument in the YAML above with all jobs that are using self-hosted runners. To do this, replace ALL_OTHER_JOBS with a list of jobs denoted by name.