forked from trussworks/ecs-scaledown
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v1.1.0: simplify logic, remove extra cases
- Loading branch information
1 parent
9be9dfd
commit b83ce45
Showing
6 changed files
with
104 additions
and
442 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,23 @@ | ||
# ecs-scaledown | ||
# github-action-ecs-scale | ||
|
||
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. | ||
scale an ECS service's desired count up/down to a desired value. | ||
|
||
## What it does | ||
|
||
1. Configure AWS credentials. Uses existing action: | ||
[aws-actions/configure-aws-credentials](https://github.com/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](https://github.com/trussworks/ecs-scaleup) action. | ||
1. Uses the AWS SDK for JavaScript to update the specified ECS Service's `desired count` attribute to a given value. | ||
|
||
### General Usage | ||
|
||
```yaml | ||
ecs-scaledown: | ||
name: Scale down ECS Service | ||
needs: [ecs-scaleup, ALL_OTHER_JOBS] | ||
name: Scale down ECS Service to zero | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: ecs-scaledown | ||
uses: trussworks/ecs-scaledown | ||
uses: zachelrath/github-action-ecs-scale | ||
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 | ||
service: your-service | ||
cluster: your-cluster | ||
desired-count: 0 | ||
``` | ||
### 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](https://github.com/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: | ||
|
||
```yaml | ||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.