Skip to content

Commit

Permalink
Updates README to a respectable state
Browse files Browse the repository at this point in the history
  • Loading branch information
Gowiem committed Jun 20, 2020
1 parent 6a724ea commit 4800565
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 17 deletions.
88 changes: 74 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,42 @@
# ecsrun [![Powered By: GoReleaser](https://img.shields.io/badge/powered%20by-goreleaser-green.svg?style=flat-square)](https://github.com/goreleaser) [![Release](https://img.shields.io/github/release/masterpointio/ecsrun.svg)](https://github.com/masterpointio/ecsrun/releases/latest)
# ecsrun

Easily run one-off tasks against an ECS Task Definition.
[![Go Report Card](https://goreportcard.com/badge/github.com/masterpointio/ecsrun)](https://goreportcard.com/report/github.com/masterpointio/ecsrun)
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/masterpointio/ecsrun/Go%20Build%20%26%20Test)](https://github.com/masterpointio/ecsrun/actions?query=workflow%3A%22Go+Build+%26+Test%22)
[![Powered By: GoReleaser](https://img.shields.io/badge/powered%20by-goreleaser-green.svg?style=flat-square)](https://github.com/goreleaser)
[![Release](https://img.shields.io/github/release/masterpointio/ecsrun.svg)](https://github.com/masterpointio/ecsrun/releases/latest)

Easily run one-off tasks against an ECS Task Definition 🐳

## Purpose

`ecsrun` is a small go CLI app to provide a config file based approach to executing one-off ECS Tasks. The ECS `RunTask` command is a pain to write out on the command line, so this tool provides an easy way to wrap any common `RunTask` executions you do in a simple yaml file.

## Install

#### Homebrew
#### From Homebrew

```
brew install masterpointio/tap/ecsrun
```

#### Go Get
#### From Go Get

```
go get -u github.com/masterpointio/ecsrun
```

## Usage

### Invoking with `ecsrun.yaml`
#### Invoking with `ecsrun.yaml` (easiest)

Given you have an `ecsrun.yaml` like so:

```yaml
default: &default
cluster: "mp-test-cluster"
task: "mp-test-alpine"
security-group: "sg-06c65c3206401917e"
subnet: "subnet-0c97e16b8a52b4b86"
cluster: mp-test-cluster
task: mp-test-alpine
security-group: sg-06c65c3206401917e
subnet: subnet-0c97e16b8a52b4b86
public: false
cmd:
- bash
Expand All @@ -50,24 +55,79 @@ migrate:

You can invoke two easy commands to spin up a one-off task:

```
```bash
# Invoke the 'mp-test-alpine' task definition with the 'hello world' `CMD`
ecsrun --config default
ecsrun

# Invoke the 'mp-test-django' task definition with the `manage.py migrate` `CMD`
ecsrun --config migrate
```

TODO: Add more here
#### From Command Line

`ecsrun` supports all of the config options via CLI arguments as well:

```bash
ecsrun --cluster mp-example-task-runner \
--subnet subnet-0c97e16b8a52b4b86 \
--security-group sg-06c65c3206401917e \
--cmd "bash,-c,echo,\"Hello world\"" \
--region us-west-2 \
--public \
--verbose
```

You can use this in combination with a configuration file to only override certain arguments:

```bash
ecsrun --config migrate
--subnet ${DIFFERENT_SUBNET} \
--public
```

#### From Environment Variables

You can also pass configuration to `ecsrun` via environment variables:

```bash
export AWS_PROFILE="mp-gowiem"
export AWS_ACCESS_KEY_ID="123"
export AWS_SECRET_ACCESS_KEY="SECRET123"
export ECSRUN_CMD="bash,-c,echo,\"Hello world\""
export ECSRUN_CLUSTER="mp-testing-cluster"
export ECSRUN_TASK="mp-testing-task"
export ECSRUN_SECURITY_GROUP="sg-06c65c3206401917e"
export ECSRUN_SUBNET="subnet-0c97e16b8a52b4b86"
export ECSRUN_VERBOSE="true"

# Invoke a dry run to check the resulting `RunTaskInput` configuration
ecsrun --dry-run
```

#### Initialize an empty `ecsrun.yaml`

Don't have an `ecsrun.yaml` file yet? Initialize the scaffold of one in your current directory:

```
ecsrun init
```

#### More

Be sure to check out `ecsrun help` for more info and full configuration options.

## Inspiration

I wrote the included `run_command` bash script for a client project as admin tasks were quite common on the project (migrations, django `manage.py` jobs, debugging, etc). This script was pretty ugly (what bash script isn't honestly), but it got the job done. I wanted to build a new project in golang to try out the langauge, and converting `run_command` to something with a bit more grace seemed like a fun project. `ecsrun` is the result!

## Roadmap

- [x] Support basic CLI usage
- [x] Support local config file
- [x] Support `--dryrun` Flag
- [x] Add more tests
- [ ] Add a `ecsrun init` command to generate the ecsrun.yml config file.
- [x] Add a `ecsrun init` command to generate the ecsrun.yml config file.
- [ ] Support log group / stream tailing of initiated task
- [ ] Support selection of resources similar to gossm (cluster, task def, task def version, etc etc)
- [ ] Support selection of resources similar to gossm (cluster, task def, task def revision, etc etc)
- [ ] Support validation of given params: cluster, definition name, revision, subnet ID, SG ID, ect.
- [ ] Support EC2 usage.
3 changes: 1 addition & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ var (
var rootCmd *cobra.Command = &cobra.Command{
Use: "escrun",
Short: "Easily run one-off tasks against an ECS Cluster",
Long: `
ecsrun is a CLI tool that allows users to run one-off administrative tasks
Long: `ecsrun is a CLI tool that allows users to run one-off administrative tasks
using their existing Task Definitions.`,

Run: func(cmd *cobra.Command, args []string) {
Expand Down
8 changes: 7 additions & 1 deletion example/configs/ecsrun.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ default: &default
cluster: "test-cluster"
task: "test-task"
security-group: "sg1"
subnet: "subnet-54321"
cmd:
- bash
- -c
- echo
- "hello world"

custom:
<<: *default
Expand All @@ -10,4 +16,4 @@ custom:
- bash
- -c
- echo
- "hello world"
- "custom"

0 comments on commit 4800565

Please sign in to comment.