Categorygithub.com/surminus/flecs
modulepackage
0.1.2
Repository: https://github.com/surminus/flecs.git
Documentation: pkg.go.dev

# README

Flecs GitHub Actions

Flexible ECS deployment!

Why Flecs?

There are many deployment tools for Amazon ECS, but these almost always only allow updating a service.

Deployment is more than updating a service: it is often a combination of different tasks specific to your organisation. These tasks then must be configured in Continuous Deployment tool of choice.

Flecs intends to make pipelines a first class citizen. This means your application deployments become a whole lot more portable.

Versus other tools

I'm writing this for fun, so I would strongly recommend using other tools.

Hashicorp Waypoint and AWS Copilot are two that will probably become the de-facto way to deploy to ECS in the future.

Install

Grab a binary from releases.

Configuration

All configuration exists in a single flecs.yaml file.

Pipeline

The pipeline is configured by specifying the type of task. Each task type has it's own configuration options:

NameWhat
scriptRuns a local script
dockerBuilds a Docker image and pushes it to an ECR repository
serviceCreates and/or updates an ECS service
taskRuns a one-off task in the ECS cluster

An example configuring the pipeline:

pipeline:
  - type: script
    inline: uptime
  - type: script
    path: path/to/script
  - type: docker
    dockerfile: Dockerfile
  - type: service
    service: web
    definition: nginx
  - type: task
    task: uptime

Services

Services configure how to run a service in the cluster. The name of the service is referred to by the service pipeline step:

pipeline:
  - type: service
    service: web

services:
  web:
    name: nginx
    definition: nginx

Definitions

Definitions configure your task definitions. The name of the definition is referred to by a service definition, or the task pipeline step:


pipeline:
  - type: service
    service: web

services:
  web:
    name: nginx
    definition: nginx

definitions:
  nginx:
    containers:
    - name: nginx
      image: nginx

Tasks

Tasks specify how a one-off task should be run. They require a task definition, and can also specify a command:

pipeline:
  - type: task
    task: uptime

definitions:
  ubuntu:
    container:
    - name: ubuntu
      image: ubuntu

tasks:
  uptime:
    definition: ubuntu
    command: uptime

Environments

Setting different environments is completely optional, but if you've configured your service and then want to deploy to a Production environment, you can configure every option within environments configuration:

subnet_names:
  - default-subnet-a

environments:
  production:
    region: eu-west-1
    subnet_names:
      - production-subnet-a
      - production-subnet-b

Using flecs -e production will mean that Production configuration is used.

Expressions

You can refer to the environment, tag or project_name as an expression in the configuration:

cluster_name: {{ environment }}-cluster

Running flecs -e production will mean the cluster name is production-cluster.

This means you can use the {{ tag }} expression for use with images:

pipeline:
  - type: service
    service: web

services:
  web:
    definition: web

definitions:
  web:
    containers:
      - name: my_container
        image: surminus/my_container:{{ tag }}

If tag is not specified in configuration or via the --tag CLI flag, it will default to the commit SHA of the current working directory.

# Functions

CheckError will display any errors and quit if found.
LoadConfig will load all configuration options if they exist, allowing environment specific options to override top level options.

# Variables

Log allows us to output in a consistent way everywhere.

# Structs

Client sets up a client with configurable options.
Clients contains all AWS clients we're using.
Config represents all options that can be configured by a flecs config file.
ConfigOptions contains all the configuration options that are configurable either at a per environment level or at the plain top level.
Container sets up a container definition.
Definition will be used to configure task definitions.
DockerArgs is a defined list of different arguments to pass to Docker.
DockerStep represents the docker step, that builds and pushes Docker images.
HealthCheck is used to check the health of a container.
LoadBalancer configures a load balancer that has been created elsewhere.
MountPoint allows setting up a mount point on a container.
Script runs an arbitary command.
Service contains the parameters for creating a service.
ServiceStep will update a Service.
Step describes a step in the pipeline.
Task specifies details of the task to be run.
TaskStep runs a one-off task in the cluster, specifying a task that should be defined elsewhere.
VolumeFrom allows sharing a volume with another container.