Giter VIP home page Giter VIP logo

ecs_task_runner's Introduction

ecs_task_runner

Helper tools to run a task on AWS ECS and follow the logs

Why?

The use case why I created this script is that we want to run ECS tasks in Jenkins and directly see the output of the tasks that are being run. This is very cumbersome to achieve using the aws cli. Hence this library.

Installation

Until this package is distributed as pip package, you have to install it directly from this repository:

pip install git+https://github.com/moee/[email protected]

Usage

Example 1: Jenkins Integration

#!/bin/sh
pip install git+https://github.com/moee/[email protected]

python << END
import ecstaskrunner, sys, logging

logging.basicConfig()
logging.getLogger('ecstaskrunner').setLevel(logging.INFO)

sys.exit(
    ecstaskrunner.run_task(
        cluster="YOUR-CLUSTER-NAME",
        taskDefinition='YOUR-TASK-DEFINITION',
    )
)
END

This runs the task named YOUR-TASK-DEFINITION on the cluster YOUR-CLUSTER-NAME, displays all the output (Note: this only works if the container definition uses the awslogs driver) and waits for the task to stop. Only if all containers have stopped and exited with 0 the job will be marked as success.

Example 2: Get the log output of a task

import ecstaskrunner
task = ecstaskrunner.task.Task(cluster='YOUR-CLUSTER-NAME', taskId='YOUR-TASK-ID')
for container in task.containers:
    for line in task.containers[container].get_log_events():
        print "%s: %s" % (container, line)

ecs_task_runner's People

Contributors

moee avatar

Stargazers

Levi McDonough avatar velniukas avatar Gil Sousa avatar

Watchers

 avatar James Cloos avatar Levi McDonough avatar Gil Sousa avatar

Forkers

kununu

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.