Giter VIP home page Giter VIP logo

ecs-task's Introduction

Build GitHub release GoDoc Renovate

ecs-task

ecs-task is a command line tool to run a task on the ECS. The feature is

  • Wait for completion of the task execution
  • Get logs from CloudWatch Logs and output in stream

This is a command line tool, but you can use task as a package. So when you write own task execition script for AWS ECS, you can embed task package in your golang source code and customize task recipe. Please check godoc.

Install

Get binary from GitHub:

$ wget https://github.com/h3poteto/ecs-task/releases/download/v0.2.1/ecs-task_v0.2.1_linux_amd64.zip
$ unzip ecs-task_v0.2.1_linux_amd64.zip
$ ./ecs-task help
Run a task on ECS

Usage:
  ecs-task [command]

Available Commands:
  help        Help about any command
  run         Run a task on ECS
  version     Print the version number

Flags:
  -h, --help             help for ecs-task
      --profile string   AWS profile (detault is none, and use environment variables)
      --region string    AWS region (default is none, and use AWS_DEFAULT_REGION)
  -v, --verbose          Enable verbose mode

Use "ecs-task [command] --help" for more information about a command.

Usage

Please provide a command to --command.

$ ./ecs-task run --cluster=base-default-prd --container=task --task-definition=fascia-web-prd-task --command="echo 'hoge'" --region=ap-northeast-1
[2018-11-10 19:13:15 +0900 JST] hoge

And if the command is failed on ECS, ecs-task exit with error.

$ ./ecs-task run --cluster=base-default-prd --container=task --task-definition=fascia-web-prd-task --command="hoge" --region=ap-northeast-1
[2018-11-10 18:29:24 +0900 JST] ./entrypoint.sh: exec: line 13: hoge: not found
FATA[0015] exit code: 127
exit status 1
$ echo $?
1

If you want to run the task as Fargate, please provide fargate flag and your subnet IDs.

$ ./ecs-task run --cluster=base-default-prd --container=task --task-definition=fascia-web-prd-task --command='echo "hoge"' --fargate=true --subnets='subnet-12easdb,subnet-34asbdf' --region=ap-northeast-1

AWS IAM Policy

Below is a basic IAM Policy required for ecs-task.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "AllowUserToECSTask",
      "Effect": "Allow",
      "Action": [
        "ecs:DescribeTaskDefinition",
        "ecs:RunTask",
        "ecs:DescribeTasks",
        "ecs:ListTasks",
        "logs:DescribeLogStreams",
        "logs:GetLogEvents",
        "iam:PassRole"
      ],
      "Resource": "*"
    }
  ]
}

License

The package is available as open source under the terms of the MIT License.

ecs-task's People

Contributors

dependabot-preview[bot] avatar h3poteto avatar kamatama41 avatar renovate-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ecs-task's Issues

Dependabot can't resolve your Go dependency files

Dependabot can't resolve your Go dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

github.com/h3poteto/ecs-task/cmd: cannot find module providing package github.com/h3poteto/ecs-task/cmd

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Check exit code only target container

If the task has some containers, now ecs-task checks exit code all of them. So if a sidecar container exit with 137 (essential container kill), ecs-task exit with 137.

It is not expected behavior. Please check only target container.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/go-mod-fix.yml
  • actions/checkout v3
  • at-wat/go-sum-fix-action v0
.github/workflows/release.yml
  • actions/setup-go v3
  • alexellis/upload-assets 0.3.0
.github/workflows/reviewdog.yml
  • actions/setup-go v3
  • reviewdog/action-setup v1
.github/workflows/test.yml
  • actions/setup-go v3
gomod
go.mod
  • go 1.18
  • github.com/aws/aws-sdk-go v1.44.14
  • github.com/mattn/go-shellwords v1.0.12
  • github.com/pkg/errors v0.9.1
  • github.com/sirupsen/logrus v1.8.1
  • github.com/spf13/cobra v1.4.0
  • github.com/spf13/viper v1.12.0

  • Check this box to trigger a request for Renovate to run again on this repository

RequestError: send request failed

Hi,

I want to report a problem with this tool. I'm using the latest version on Mac 10.12.6.

Looks like it can't reach ECS server when --region flag is supplied. But I proceed without that flag, it complained.

~ ᐅ ecs-task run --cluster=myCluster --container=task --task-definition=myTaskDef --command="echo 'hello'" --profile=myProfile --region=ap-southeast-1a --verbose
FATA[0000] RequestError: send request failed
caused by: Post https://ecs.ap-southeast-1a.amazonaws.com/: dial tcp: lookup ecs.ap-southeast-1a.amazonaws.com on 8.8.8.8:53: no such host

~ ᐅ ecs-task run --cluster=myCluster --container=task --task-definition=myTaskDef --command="echo 'hello'" --profile=myProfile --verbose
FATA[0000] MissingRegion: could not find region configuration

Am I missing something here?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.