• Stars
    star
    121
  • Rank 293,924 (Top 6 %)
  • Language
    Go
  • License
    MIT License
  • Created about 5 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

ecschedule is a tool to manage ECS Scheduled Tasks.

ecschedule

Test Status MIT License PkgGoDev

ecschedule is a tool to manage ECS Scheduled Tasks.

Synopsis

% ecschedule [dump|apply|run|diff] -conf ecschedule.yaml -rule $ruleName

Description

The ecschedule manages ECS Schedule tasks using a configuration file (YAML, JSON or Jsonnet format) like following.

region: us-east-1
cluster: clusterName
rules:
- name: taskName1
  description: task 1
  scheduleExpression: cron(30 15 ? * * *)
  taskDefinition: taskDefName
  containerOverrides:
  - name: containerName
    command: [subcommand1, arg]
    environment:
      HOGE: foo
      FUGA: {{ must_env `APP_FUGA` }}
- name: taskName2
  description: task2
  scheduleExpression: cron(30 16 ? * * *)
  taskDefinition: taskDefName2
  containerOverrides:
  - name: containerName2
    command: [subcommand2, arg]

Installation

% brew install Songmu/tap/ecschedule
# or
% go install github.com/Songmu/ecschedule/cmd/ecschedule@latest

GitHub Actions

Action Songmu/ecschedule@main installs ecschedule binary for Linux into /usr/local/bin. This action runs install only.

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: Songmu/ecschedule@main
      - run: |
          ecschedule -conf ecschedule.yaml apply -all

Quick Start

dump configuration YAML

% ecschedule dump --cluster clusterName --region us-east-1 > ecschedule.yaml

edit and adjust configuration file after it.

apply new or updated rule

% ecschedule -conf ecschedule.yaml apply -rule $ruleName

Before you apply it, you can check the diff in the following way.

% ecschedule -conf ecschedule.yaml diff -rule $ruleName

run rule

Execute run subcommand when want execute arbitrary timing.

% ecschedule -conf ecschedule.yaml run -rule $ruleName

Using the -prune option to manage rules

In version v0.9.1 and earlier, when rules were renamed or deleted from the configuration, the old rules remained and had to be deleted manually. With the -prune option introduced in v0.10.0, you can now automatically remove these old rules.

% ecschedule -conf ecschedule.yaml apply -all -prune

To see which rules would be deleted without actually removing them, combine with the -dry-run option.

% ecschedule -conf ecschedule.yaml apply -all -prune -dry-run

Functions

You can use following functions in the configuration file.

  • env
    • expand environment variable or using default value
    • {{ env "ENV_NAME" "DEFAULT_VALUE" }}
  • must_env
    • expand environment variable
    • {{ must_env "ENV_NAME" }}

inspired by ecspresso.

Plugins

tfstate

tfstate plugin introduces a template function tfstate.

region: us-east-1
cluster: api
role: ecsEventsRole
rules:
- name: hoge-task-name
  description: hoge description
  scheduleExpression: cron(0 0 * * ? *)
  taskDefinition: task1
  group: xxx
  platform_version: 1.4.0
  launch_type: FARGATE
  network_configuration:
    aws_vpc_configuration:
      subnets:
      - {{ tfstate `aws_subnet.private-a.id` }}
      - {{ tfstate `aws_subnet.private-c.id` }}
      security_groups:
      - {{ tfstatef `data.aws_security_group.default['%s'].id` `first` }}
      - {{ tfstatef `data.aws_security_group.default['%s'].id` `second` }}
      assign_public_ip: ENABLED
  containerOverrides:
  - name: container1
    command: ["subcmd", "argument"]
    environment:
      HOGE_ENV: {{ env "DUMMY_HOGE_ENV" "HOGEGE" }}
    cpu: 1024
    memory: 1024
    memoryReservation: 512
  dead_letter_config:
    sqs: queue1
  propagateTags: TASK_DEFINITION
plugins:
- name: tfstate
  config:
    path: testdata/terraform.tfstate    # path to tfstate file
      # or url: s3://my-bucket/terraform.tfstate

{{ tfstate "resource_type.resource_name.attr" }} will expand to an attribute value of the resource in tfstate.

{{ tfstatef "resource_type.resource_name['%s'].attr" "index" }} is similar to {{ tfstatef "resource_type.resource_name['index'].attr" }}. This function is useful to build a resource address with environment variables.

{{ tfstatef `aws_subnet.ecs['%s'].id` (must_env `SERVICE`) }}

Pitfalls

Rule Name Uniqueness and Overwrite Risks

ecschedule is designed to guarantee the uniqueness of job definitions by rule name in the configuration file.

If ecschedule is run in an environment where a Rule that is not managed by ecschedule already exists, ecschedule will overwrite that Rule. If you do not intend to overwrite, please ensure that the names written in the configuration file do not duplicate with existing Rules.

Note on Previous Versions

In versions v0.9.1 and earlier, there were issues related to rule name changes causing garbage definitions and rules not being deleted from AWS when removed from the configuration file. These issues have been addressed in version v0.10.0 with the introduction of the -prune option.

Author

Songmu

More Repositories

1

ghq-handbook

272
star
2

ghch

Generate changelog from git history, tags and merged pull requests
Go
204
star
3

horenso

Command wrapper for reporting the result. It is useful for cron jobs.
Go
151
star
4

tagpr

automatically creates and updates a pull request for unreleased items, tag them when they are merged, and create releases.
Go
144
star
5

prompter

golang utility for easy prompting
Go
143
star
6

gocredits

creates CREDITS file from LICENSE files of dependencies
Go
95
star
7

ghg

Get the executable from github releases easily
Go
88
star
8

goxz

Just do cross building and archiving go tools conventionally
Go
84
star
9

timeout

Timeout invocation. Go porting of GNU timeout and able to use as Go package
Go
73
star
10

make2help

Utility for self-documented Makefile
Go
63
star
11

gotesplit

Splits the testing in Go into a subset and run it. It is useful for the CI environment.
Go
58
star
12

flextime

flextime improves time testability by replacing the backend clock flexibly.
Go
49
star
13

kibelasync

kibela client
Go
39
star
14

retry

Go
32
star
15

axslogparser

Fairly accurate access Log Parser
Go
27
star
16

peep

Watch a process and execute specified command for notification when finished
Go
27
star
17

godzil

A Go Authoring tool
Go
25
star
18

p5-Riji

git based simple static site generator mainly for blogging
Perl
25
star
19

go-httpdate

Well parsing and dealing the various date formats automatically
Go
22
star
20

maltmill

create and update Homebrew thrid party Formulae
Go
20
star
21

html-shakan

HTML::Shakan is a yet another form generator
Perl
18
star
22

goshim

Better `go run`. Build go codes transparently and exec
Go
16
star
23

crontabparser

utility to validate crontab and to create your own crond
Go
16
star
24

smartcache

Go
15
star
25

go-ltsv

Go
15
star
26

replaceablewriter

Go
12
star
27

strrand

Go
12
star
28

dotfiles

dotfiles
Vim Script
12
star
29

go-memcached-tool

go porting from memcached-tool in Perl (only support display and dump mode)
Go
10
star
30

timestamper

text transformer to put timestamps. It is very useful for logging.
Go
10
star
31

gh2changelog

Go
9
star
32

deglacer

Go
9
star
33

Yapafi

Yet Anather PHP Application Framework Interface
PHP
8
star
34

App-LJ

Perl
8
star
35

qnap-mackerel-agent

mackerel-agent installer for QNAP
Go
7
star
36

enslaver

Go
7
star
37

num

Go
7
star
38

wrapcommander

Go
6
star
39

gitconfig

Go
5
star
40

p5-L

perl module loader for oneliner
Perl
5
star
41

jfill

Assemble command using JSON via STDIN and execute it
Go
5
star
42

p5-Mackerel-Webhook-Receiver

Perl
5
star
43

postailer

Utility for reading files to start reading from the position read last time and also care file rotation
Go
5
star
44

p5-Text-Markdown-GitHubAPI

Perl
4
star
45

p5-Const-Common

Perl
4
star
46

Github-Hooks-Receiver

Perl
4
star
47

p5-Plack-App-Directory-Markdown

Perl
4
star
48

p5-DBIx-FixtureLoader

Perl
4
star
49

Puncheur

Perl
4
star
50

JapaneseZipCodeData-AutoDownloadAndExtract

Perl
3
star
51

GitDDL-Migrator

Perl
3
star
52

p5-HTTP-MobileAgent-Plugin-SmartPhone

Perl
3
star
53

action-shodo-lint

Shell
2
star
54

p5-MySQL-Warmer

Perl
2
star
55

homebrew-tap

Ruby
2
star
56

p5-Module-Setup-Flavor-ArkDBIC

Perl
2
star
57

p5-Redis-LeaderBoard

Perl
2
star
58

App-tmclean

Perl
2
star
59

diet-wiki

JavaScript
2
star
60

p5-App-CPANGhq

Perl
2
star
61

mackerel-plugin-httpstat

Go
2
star
62

p5-Teng-Plugin-SearchJoined

Perl
2
star
63

HTML-HTML5Forms

FormBuilder for HTML5
Perl
1
star
64

p5-Kannuki

Management htpasswd file
Perl
1
star
65

Math-CheckDigits

Perl Module to generate and test check digits
Perl
1
star
66

p5-Plack-Middleware-Auth-QueryString

Perl
1
star
67

p5-Plack-Middleware-HubSignature

Perl
1
star
68

p5-Encode-JP-Mobile-UnicodeEmoji

Perl
1
star
69

songmu_css_base

1
star
70

App-KV2JSON

Perl
1
star
71

Git-Repository-FileHistory

Perl
1
star
72

HyCycjk

Haiyou yige CGI yingyong chengxu jiemian kuangjia
Perl
1
star
73

p5-GitMasterData

Perl
1
star
74

p5-Cache-Redis

Perl
1
star
75

p5-DBIx-CSVDumper

Perl
1
star
76

gitsemvers

Go
1
star
77

p5-Parse-CommandLine

Perl
1
star
78

swimmy

Go
1
star
79

slack2slack

Go
1
star
80

Github-Hooks-Manager

Perl
1
star
81

Text-KuaiWiki

Wiki Formatter used on KuaiWiki
Perl
1
star
82

p5-Const-Common-Generator

Perl
1
star
83

p5-Config-PL

Perl
1
star
84

p5-App-StatusBin

Perl
1
star
85

p5-Math-RandomTable

Perl
1
star
86

p5-Data-GoogleSpreadsheet-Fetcher

Perl
1
star
87

ansible-roles-mackerel-agent

Python
1
star
88

p5-Test-mysqld-DatadirDumper

Perl
1
star
89

p5-SWF-Changer

Perl
1
star
90

p5-WinPB

Perl
1
star
91

git-rss

Go
1
star
92

ark-jobeet-2011

Perl
1
star
93

p5-App-RunCron

Perl
1
star
94

mkrp

Go
1
star
95

p5-blockdiagServer

Perl
1
star