civitaspo / digdag-operator-ecs_task

digdag plugin for AWS ECS Task
Apache License 2.0
29 stars 9 forks source link

digdag-operator-ecs_task

Jitpack Release CI Status Badge Test CI Status Badge Digdag

digdag plugin for AWS ECS Task.

Overview

Usage

_export:
  plugin:
    repositories:
      - https://jitpack.io
    dependencies:
      - pro.civitaspo:digdag-operator-ecs_task:0.1.6
  ecs_task:
    auth_method: profile
    tmp_storage:
      type: s3
      uri: ${output}
    family_prefix: hello-
    cluster: ${cluster}
    network_mode: host
    memory: 1 GB
    task_role_arn: ${task_role_arn}

+ecs_task.run:
  +step1:
    ecs_task.run>:
    def:
      network_mode: host
      container_definitions:
        - name: step1
          image: civitaspo/python-awscli:latest
          command: [echo, step1]
          essential: true
          memory: 500
          cpu: 1
      family: step1
    count: 1
  +step2:
    ecs_task.run>:
    def:
      network_mode: host
      container_definitions:
        - name: step2
          image: civitaspo/python-awscli:latest
          command: [echo, step2]
          essential: true
          memory: 500
          cpu: 1
      family: step2
    count: 1
  +step3:
    ecs_task.run>:
    def:
      network_mode: host
      container_definitions:
        - name: step3
          image: civitaspo/python-awscli:latest
          command:
            - sh
            - -c
            - echo '{"store_params":{"civi":"taspo"}}' | aws s3 cp - ${output}/${session_uuid}.json
          essential: true
          memory: 500
          cpu: 1
      task_role_arn: ${task_role_arn}
      family: step3
    count: 1
    result_s3_uri: ${output}/${session_uuid}.json

  +step4:
    echo>: ${civi}

+ecs_task.sh:
  +step0:
    ecs_task.sh>: env
    image: civitaspo/digdag-awscli:latest
    _export:
      message:
        message: 'hello ecs_task.rb'
        created_by: civitaspo

+ecs_task.rb:
  +step0:
    ecs_task.rb>: echo
    require: echo
    gem_install: [awesome_print]
    image: civitaspo/ruby-awscli:latest
    _export:
      message:
        message: 'hello ecs_task.rb'
        created_by: civitaspo

+ecs_task.py:
  +step0:
    ecs_task.py>: echo.echo
    pip_install: [PyYaml]
    image: civitaspo/python-awscli:latest
    _export:
      message:
        message: 'hello ecs_task.py'
        created_by: civitaspo

+ecs_task.embulk:
  _export:
    path_prefix: ./csv/
  +dig:
    ecs_task.embulk>:
      in:
        type: file
        path_prefix: ${path_prefix}
        parser:
          charset: UTF-8
          newline: CRLF
          type: csv
          delimiter: ','
          quote: '"'
          escape: '"'
          null_string: 'NULL'
          skip_header_lines: 0
          columns:
            - {name: id, type: long}
            - {name: comment, type: string}
      out:
        type: stdout
    image: civitaspo/embulk-awscli:latest

  +file:
    ecs_task.embulk>: template.yml
    image: civitaspo/embulk-awscli:latest

See example.

Configuration

Remarks

Common Configuration

System Options

Define the below options on properties (which is indicated by -c, --config).

Secrets

Options

Configuration for ecs_task.register> operator

Configuration for ecs_task.run> operator

The configuration is the same as the snake-cased RunTask API.

In addition, the below configurations exist.

Configuration for ecs_task.wait> operator

Configuration for ecs_task.result> operator

(Experimental) Scripting Operators

digdag-operator-ecs_task supports some scripting operators such as ecs_task.py, ecs_task.rb. Originally I wanted to provide ecs_task as one of the implementations of CommandExecutor provided by digdag, but users cannot extend the current CommandExecutor as written in this issue: [feature-request] Use Custom CommandExecutors. Therefore, this plugin implements Scripting Operator on its own. Of course, the usage is the same as the Scripting Operator provided by digdag. When the issue is resolved, I will reimplement it using the CommandExecutor of digdag.

Scripting Operators Common Configurations

Configuration for ecs_task.py> operator

Configuration for ecs_task.rb> operator

Configuration for ecs_task.sh> operator

Configuration for ecs_task.embulk> operator

Development

Run an Example

1) build

./gradlew publish

Artifacts are build on local repos: ./build/repo.

2) get your aws profile

aws configure

3) run an example

./example/run.sh ${ECS Cluster Name} ${S3 URI Prefix for tmp storage} ${ECS Task Role ARN}

(TODO) Run Tests

./gradlew test

ChangeLog

CHANGELOG.md

License

Apache License 2.0

Author

@civitaspo