This repository has been archived by the owner on Jan 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from trussworks/cht-implement-functionality
Merge full functionality
- Loading branch information
Showing
14 changed files
with
48,843 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"env": { | ||
"commonjs": true, | ||
"es6": true, | ||
"node": true, | ||
"jest": true | ||
}, | ||
"extends": "eslint:recommended", | ||
"globals": { | ||
"Atomics": "readonly", | ||
"SharedArrayBuffer": "readonly" | ||
}, | ||
"parserOptions": { | ||
"ecmaVersion": 2018 | ||
}, | ||
"rules": { | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules/ | ||
|
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
repos: | ||
- repo: git://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.0.1 | ||
hooks: | ||
- id: check-merge-conflict | ||
- id: detect-private-key | ||
- id: trailing-whitespace | ||
|
||
- repo: git://github.com/igorshubovych/markdownlint-cli | ||
rev: v0.28.1 | ||
hooks: | ||
- id: markdownlint |
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 +1,52 @@ | ||
# ecs-scaledown | ||
# 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](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. | ||
|
||
```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" | ||
service: github-actions-runner | ||
cluster: github-runner | ||
``` | ||
**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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: 'Deprovision GitHub Runners' | ||
description: 'Scale down ECS service count' | ||
inputs: | ||
aws-access-key-id: | ||
description: >- | ||
AWS Access Key ID. This input is required if running in the GitHub hosted environment. | ||
It is optional if running in a self-hosted environment that already has AWS credentials, | ||
for example on an EC2 instance. | ||
required: false | ||
aws-secret-access-key: | ||
description: >- | ||
AWS Secret Access Key. This input is required if running in the GitHub hosted environment. | ||
It is optional if running in a self-hosted environment that already has AWS credentials, | ||
for example on an EC2 instance. | ||
required: false | ||
aws-region: | ||
description: 'Your AWS region' | ||
required: true | ||
default: 'us-east-1' | ||
service: | ||
description: 'The name of the ECS service.' | ||
required: true | ||
cluster: | ||
description: 'The name of the ECS cluster the service belongs to.' | ||
required: true | ||
runs: | ||
using: 'node12' | ||
main: 'dist/index.js' | ||
post: 'dist/cleanup/index.js' |
Oops, something went wrong.