ecsched

package module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2020 License: MIT Imports: 20 Imported by: 0

README

ecsched

Test Status MIT License GoDoc

ecsched is a tool to manage ECS Scheduled Tasks.

Synopsis

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

Description

The ecsched manages ECS Schedule tasks using a YAML configuration file like following.

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

Installation

% go get github.com/Songmu/ecsched/cmd/ecsched

Quick Start

dump configuration YAML
% ecsched dump --cluster clusterName --region us-east-1 > ecsched.yaml

edit and adjust configuration file after it.

apply new or updated rule
% ecsched -conf ecsched.yaml apply -rule $ruleName

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

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

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.

Author

Songmu

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAWSAccountID

func GetAWSAccountID(sess *session.Session) (string, error)

GetAWSAccountID returns id

func NewAWSSession

func NewAWSSession() (*session.Session, error)

NewAWSSession return new AWS session

func Run

func Run(argv []string, outStream, errStream io.Writer) error

Run the ecsched

Types

type BaseConfig

type BaseConfig struct {
	Region    string `yaml:"region"`
	Cluster   string `yaml:"cluster"`
	AccountID string `yaml:"-"`
}

BaseConfig baseconfig

type Config

type Config struct {
	Role        string `yaml:"role,omitempty"`
	*BaseConfig `yaml:",inline"`
	Rules       []*Rule `yaml:"rules"`
}

Config config

func LoadConfig

func LoadConfig(r io.Reader, accountID string) (*Config, error)

LoadConfig loads config

func (*Config) GetRuleByName

func (c *Config) GetRuleByName(name string) *Rule

GetRuleByName gets rule by name

type ContainerOverride

type ContainerOverride struct {
	Name        string            `yaml:"name"`
	Command     []string          `yaml:"command,flow"` // ,flow
	Environment map[string]string `yaml:"environment,omitempty"`
}

ContainerOverride overrids container

type Rule

type Rule struct {
	Name               string `yaml:"name"`
	Description        string `yaml:"description,omitempty"`
	ScheduleExpression string `yaml:"scheduleExpression"`
	Disabled           bool   `yaml:"disabled,omitempty"` // ENABLE | DISABLE
	*Target            `yaml:",inline"`

	*BaseConfig `yaml:",inline,omitempty"`
}

Rule the rule

func (*Rule) Apply

func (r *Rule) Apply(ctx context.Context, sess *session.Session, dryRun bool) error

Apply the rule

func (*Rule) PutRuleInput

func (r *Rule) PutRuleInput() *cloudwatchevents.PutRuleInput

PutRuleInput puts rule input

func (*Rule) PutTargetsInput

func (r *Rule) PutTargetsInput() *cloudwatchevents.PutTargetsInput

PutTargetsInput puts targets input

func (*Rule) Run

func (r *Rule) Run(ctx context.Context, sess *session.Session, noWait bool) error

Run the rule

type Target

type Target struct {
	TargetID           string               `yaml:"targetId,omitempty"`
	TaskDefinition     string               `yaml:"taskDefinition"`
	TaskCount          int64                `yaml:"taskCount,omitempty"`
	ContainerOverrides []*ContainerOverride `yaml:"containerOverrides,omitempty"`
	Role               string               `yaml:"role,omitempty"`
}

Target cluster

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL