Skip to content

Commit 40839ee

Browse files
authored
Merge pull request #41 from sonikro/major-refactoring
Major refactoring
2 parents 7e98947 + 8c9191d commit 40839ee

39 files changed

+165872
-1800
lines changed

.devcontainer/devcontainer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"image": "mcr.microsoft.com/devcontainers/typescript-node:1-18-bullseye",
77
"features": {
88
"ghcr.io/devcontainers/features/common-utils:2": {},
9-
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}
9+
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
10+
"ghcr.io/devcontainers/features/aws-cli:1": {}
1011
},
1112

1213
// Features to add to the dev container. More info: https://containers.dev/features.

.env.example

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
INPUT_TAGS=""
2+
INPUT_CPU="256"
3+
INPUT_ECS_CLUSTER_NAME=""
4+
INPUT_EXECUTION_ROLE_ARN=""
5+
INPUT_IMAGE=""
6+
INPUT_MEMORY="512"
7+
INPUT_POLLING_INTERVAL="2"
8+
INPUT_POST_COMPLETE_LOG_CYCLES="4"
9+
INPUT_REGION="us-east-1"
10+
INPUT_ROLE_ARN=""
11+
INPUT_RUN=""
12+
INPUT_SECURITY_GROUP_ID=""
13+
INPUT_SHELL="sh"
14+
INPUT_SUBNET_IDS=""
15+
INPUT_TASK_ROLE_ARN=""
16+
INPUT_VPC_ID=""
17+
AWS_PROFILE=""
18+
AWS_SDK_LOAD_CONFIG=1
19+
AWS_CONFIG_FILE=<YOUR_HOME_PATH_HERE>/.aws/saml2aws/temp_creds
20+
GITHUB_WORKSPACE=<LOCAL_FOLDER_TO_UPLOAD>
21+
NODE_ENV=development

.ghadocs.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"paths": {
3+
"action": "action.yml",
4+
"readme": "README.md"
5+
},
6+
"show_logo": true,
7+
"versioning": {
8+
"enabled": true,
9+
"override": "",
10+
"prefix": "v",
11+
"branch": "main"
12+
},
13+
"owner": "sonikro",
14+
"repo": "aws-run",
15+
"title_prefix": "GitHub Action: ",
16+
"pretty": true
17+
}

.github/CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @sonikro

.vscode/launch.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Run Locally",
9+
"type": "node",
10+
"request": "launch",
11+
"cwd": "${workspaceRoot}",
12+
"runtimeExecutable": "npm",
13+
"runtimeArgs": [
14+
"run-script",
15+
"start:local"
16+
],
17+
"outputCapture": "std"
18+
}
19+
]
20+
}

.vscode/settings.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"editor.codeActionsOnSave": {
3+
"source.fixAll.eslint": true
4+
},
5+
"eslint.validate": ["typescript"]
6+
}

README.md

+29-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,33 @@
66

77
This action allows you to run a script inside of your AWS Account, without having to spin up your own runner. By leveraging the power of ECS Tasks, you can use any docker image, and run any script inside of your Job, as if that script was being executed inside of the runner, however, the script is remotely executed inside of your AWS VPC, which grants your step special access to private resources, such as RDS Databases, Internal Loadbalancers, and much more.
88

9+
<!-- start inputs -->
10+
11+
| **Input** | **Description** | **Default** | **Required** |
12+
| ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------ | ------------ |
13+
| **`role_arn`** | Role ARN to be used to create/execute the required infrastructure on AWS | | **true** |
14+
| **`execution_role_arn`** | Role ARN to be used to as execution role for the ECS Task that will run the script. Defaults to ROLE_ARN | | **false** |
15+
| **`task_role_arn`** | Role ARN to be used as Task Role arn for the ECS Task that will run the script. Defaults to ROLE_ARN | | **false** |
16+
| **`memory`** | Amount of memory to be used by the remote ECS Task (Must be a FARGATE Compatible combination. See https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-cpu-memory-error.html) | `512` | **false** |
17+
| **`cpu`** | Amount of vCPU to be used by the remote ECS Task (Must be a FARGATE Compatible combination. See https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-cpu-memory-error.html) | `256` | **false** |
18+
| **`ecs_cluster_name`** | The name of the ECS Cluster where the Tasks will run. It will be automatically created if it doesn't exist | `github-actions-aws-run` | **false** |
19+
| **`image`** | Name of the docker container to be used for the step execution | | **true** |
20+
| **`region`** | AWS Region to execute the operations | `us-east-1` | **true** |
21+
| **`security_group_id`** | Security Group to be used by the ECS Task. If not informed, a temporary security group will be created with access to the internet | | **false** |
22+
| **`run`** | Script that will be executed in the remote environment | | **true** |
23+
| **`shell`** | Name of the shell to be used in the container to execute the run script | | **true** |
24+
| **`subnet_ids`** | Subnet ID of where the Task will be executed. If no subnet_ids is specified, the task will find one automatically within the VPC | | **false** |
25+
| **`vpc_id`** | VPC ID of where the Task will be executed | | **true** |
26+
| **`tags`** | The list of custom tags to be added to all resources created on AWS with. | | **false** |
27+
| **`polling_interval`** | The amount of time (in seconds) between polling cloudwatch logs. | `2` | **false** |
28+
| **`post_complete_log_cycles`** | Number of polling cycles to try getting logs after the ecs task completes. | `4` | **false** |
29+
| **`upload_includes`** | Array of string paths to include while uploading the runner workspace to the ECS Task. Excludes apply before includes. See https://docs.aws.amazon.com/cli/latest/reference/s3/#use-of-exclude-and-include-filters | | **false** |
30+
| **`upload_excludes`** | Array of string paths to exclude while uploading the runner workspace to the ECS Task. Excludes apply before includes. See https://docs.aws.amazon.com/cli/latest/reference/s3/#use-of-exclude-and-include-filters | | **false** |
31+
| **`download_includes`** | Array of string paths to include while downloading the runner workspace from the ECS Task. Excludes apply before includes. See https://docs.aws.amazon.com/cli/latest/reference/s3/#use-of-exclude-and-include-filters | | **false** |
32+
| **`download_excludes`** | Array of string paths to exclude while downloading the runner workspace from the ECS Task. Excludes apply before includes. See https://docs.aws.amazon.com/cli/latest/reference/s3/#use-of-exclude-and-include-filters | | **false** |
33+
34+
<!-- end inputs -->
35+
936
## Benefits
1037

1138
- Use IaC (such as Terraform) to manipulate resources that are in Private VPCs (such as RDS, Opensearch, etc)
@@ -246,8 +273,9 @@ In the execution phase, the action will:
246273
- [X] Map all GitHub Contexts/ENVS into the ECS Container
247274
- [X] Ability to upload artifacts back to GitHub (if your remote execution generates artifacts)
248275
- [ ] Find a way to map environment variables from the remote shell, back to the runner (after execution)
249-
- [ ] Change the TearDown step to run as a **post** action on GHA, so take advantages of errors/cancellations
276+
- [X] Change the TearDown step to run as a **post** action on GHA, so take advantages of errors/cancellations
250277
- [ ] Make it compatible with [Windows Containers](https://aws.amazon.com/blogs/containers/running-windows-containers-with-amazon-ecs-on-aws-fargate/)
278+
251279
## Developing the action locally
252280
253281

action.yml

+27-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
name: 'aws-run'
2-
description: 'Runs a shellscript inside of an AWS VPC'
3-
author: 'Jonathan Nagayoshi'
1+
name: aws-run
2+
description: Runs a remote workload inside of an AWS VPC using ECS Fargate Tasks
3+
author: Jonathan Nagayoshi
44
inputs:
55
role_arn:
66
required: true
@@ -45,7 +45,30 @@ inputs:
4545
vpc_id:
4646
required: true
4747
description: VPC ID of where the Task will be executed
48-
48+
tags:
49+
required: false
50+
description: A multiline string in the format of KEY=VALUE of custom tags to be added to all resources created on AWS
51+
polling_interval:
52+
required: false
53+
default: 2
54+
description: The amount of time (in seconds) between polling cloudwatch logs.
55+
post_complete_log_cycles:
56+
required: false
57+
default: 4
58+
description: Number of polling cycles to try getting logs after the ecs task completes.
59+
upload_includes:
60+
required: false
61+
description: Array of string paths to include while uploading the runner workspace to the ECS Task. Excludes apply before includes. See https://docs.aws.amazon.com/cli/latest/reference/s3/#use-of-exclude-and-include-filters
62+
upload_excludes:
63+
required: false
64+
description: Array of string paths to exclude while uploading the runner workspace to the ECS Task. Excludes apply before includes. See https://docs.aws.amazon.com/cli/latest/reference/s3/#use-of-exclude-and-include-filters
65+
download_includes:
66+
required: false
67+
description: Array of string paths to include while downloading the runner workspace from the ECS Task. Excludes apply before includes. See https://docs.aws.amazon.com/cli/latest/reference/s3/#use-of-exclude-and-include-filters
68+
download_excludes:
69+
required: false
70+
description: Array of string paths to exclude while downloading the runner workspace from the ECS Task. Excludes apply before includes. See https://docs.aws.amazon.com/cli/latest/reference/s3/#use-of-exclude-and-include-filters
4971
runs:
5072
using: 'node16'
5173
main: 'dist/index.js'
74+
post: 'dist/cleanup/index.js'

0 commit comments

Comments
 (0)