Giter Club home page Giter Club logo

ecs-gen's Introduction

ecs-gen

License Build Status

Inspired by docker-gen ecs-gen lets you generate config files from templates using AWS ECS cluster information. ecs-nginx-proxy uses ecs-gen to generate nginx config files.

Installation

Go

go get -u github.com/codesuki/ecs-gen

Docker

Use the codesuki/ecs-gen docker image.

Usage

usage: ecs-gen --cluster=CLUSTER --template=TEMPLATE --output=OUTPUT [<flags>]

docker-gen for AWS ECS.

Flags:
      --help                     Show context-sensitive help (also try --help-long and --help-man).
  -r, --region="ap-northeast-1"  AWS region.
  -c, --cluster=CLUSTER          ECS cluster name.
  -t, --template=TEMPLATE        Path to template file.
  -o, --output=OUTPUT            Path to output file.
      --task="ecs-nginx-proxy"   Name of ECS task containing nginx.
  -s, --signal="nginx -s reload"
                                 Command to run to signal change.
  -f, --frequency=30             Time in seconds between polling. Must be >0.
      --once                     Only execute the template once and exit.
      --version                  Show application version.

Using with Docker

When using the docker image directly you can set all parameters using environment variables:

  • ECS_GEN_REGION
  • ECS_GEN_CLUSTER
  • ECS_GEN_TEMPLATE
  • ECS_GEN_OUTPUT
  • ECS_GEN_TASK
  • ECS_GEN_SIGNAL
  • ECS_GEN_FREQUENCY
  • ECS_GEN_ONCE

Example

Fill a template once

Running the following on the commandline ecs-gen will query the specified cluster, execute the template and exit.

ecs-gen --once --region=ap-northeast-1 --cluster="Cluster name" --template=template.tmpl --output=output.conf

Continuously update a config

To keep a config up to date try a variation of the following.

ecs-gen --signal="nginx -s reload" --cluster=my-cluster --template=nginx.tmpl --output=/etc/nginx/conf.d/default.conf

Template parameters

For now the available parameters are limited to things needed to make a nginx reverse proxy. If there is demand any information available from the AWS ECS API can be exposed.

type Container struct {
    Name    string // first host (space delimited) in VIRTUAL_HOST
    Host    string // VIRTUAL_HOST environment variable
    Port    string
    Address string
    Env     map[string]string
}

Note: The Host field can contain more than one (space delimited) hostname - this is to allow for tasks to respond to more than one hostname (for instance, example.com and www.example.com). If using the nginx template, using the VIRTUAL_HOST string example.com www.example.com would result in a single upstream definition for example.com, and a server_name of example.com www.example.com, so that nginx responds to both (an advanced use case would be to use a regex definition for the second hostname).

TODO

  • Expose more information
  • Expose VIRTUAL_HOST under environment variables instead of Host

ecs-gen's People

Contributors

codesuki avatar djwinter avatar lucaschain avatar masterful avatar simplesteph avatar

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.