UFO
AWS ECS Deploy Tool

Summary


The main command is ufo ship. Here's what it does:

  1. Builds a docker image.
  2. Registers the ECS template definition.
  3. Deploys to ECS.
  4. Creates an ELB.

Commands

ufo ship
ufo ps
ufo current
ufo apps
ufo scale
ufo docker build
ufo tasks build
ufo rollback
ufo destroy

variables/base.rb

@image = helper.full_image_name # includes the git sha tongueroo/demo-ufo:ufo-[sha].
@cpu = 128
@memory_reservation = 256
@environment = helper.env_vars(%Q{
  RAILS_ENV=production
  SITE=awesome
})

templates/main.json.erb

{
    "family": "<%= @family %>",
    "containerDefinitions": [
        {
            "name": "<%= @name %>",
            "image": "<%= @image %>",
            <% if @cpu %>
            "cpu": <%= @cpu %>,
            <% end %>
            "command": <%= @command.to_json %>,
            <% if @environment %>
            "environment": <%= @environment.to_json %>,
            <% end %>
            "essential": true
        }
    ]
}

template_definitions.rb

task_definition "example-web" do
  source "main"
  variables(
    family: task_definition_name,
    name: "web",
    awslogs_group: "ecs/example-web",
    awslogs_stream_prefix: "example",
    command: ["bin/web"]
  )
end

About


Ufo is a tool that makes building and shipping Docker containers to AWS ECS easy. At a basic level, ufo builds the docker container image, registers that image to ECS as a task definition, and then deploys that task definition to ECS by updating the service. Ufo provides a ufo ship command that deploys your code to ECS.

Ufo was built directly from real life production use cases after seeing the same patterns repeated over and over. Ufo allows you to write the AWS task definition json format file in ERB, an easy templating language. This allows you to reuse the ufo tool with multiple applications and only put the truly application specific business logic in each app code base.

Example: ufo ship demo-web


$ ufo ship
Building docker image with:
  docker build -t tongueroo/demo-ufo:ufo-2018-07-03T20-42-48-9cb7bf9 -f Dockerfile .
Sending build context to Docker daemon  295.4kB
Step 1/10 : FROM ruby:2.5.1
 ---> 857bc7ff918f
...
Step 10/10 : CMD bin/web
 ---> Using cache
 ---> c02b8f7eb183
Successfully built c02b8f7eb183
Successfully tagged tongueroo/demo-ufo:ufo-2018-07-03T20-42-48-9cb7bf9
Docker image tongueroo/demo-ufo:ufo-2018-07-03T20-42-48-9cb7bf9 built.
Docker build took 0s.
=> docker push tongueroo/demo-ufo:ufo-2018-07-03T20-42-48-9cb7bf9
The push refers to a repository [docker.io/tongueroo/demo-ufo]
f8172fcf60ff: Layer already exists
a51c4b90e727: Layer already exists
...
0f3a12fef684: Layer already exists
ufo-2018-07-03T20-42-48-9cb7bf9: digest: sha256:00eade753ff8721f7f96a505ea3bec6b1fd334c930dcecc20a2043ae9300496d size: 3458
Pushed tongueroo/demo-ufo:ufo-2018-07-03T20-42-48-9cb7bf9 docker image.
Docker push took 4s.
Building Task Definitions...
Generating Task Definitions:
  .ufo/output/demo-web.json
  .ufo/output/demo-worker.json
  .ufo/output/demo-clock.json
Task Definitions built in .ufo/output
Equivalent aws cli command:
  aws ecs register-task-definition --cli-input-json file://.ufo/output/demo-web.json
demo-web task definition registered.
Deploying demo-web...
Ensuring log group for demo-web task definition exists
Log group name: ecs/demo-web
Updating stack development-demo-web...
Generated template saved at: /tmp/ufo/development-demo-web/stack.yml
Generated parameters saved at: /tmp/ufo/development-demo-web/parameters.yml
08:43:07PM UPDATE_IN_PROGRESS AWS::CloudFormation::Stack development-demo-web User Initiated
08:43:11PM UPDATE_IN_PROGRESS AWS::ECS::Service Ecs
08:45:12PM UPDATE_COMPLETE AWS::ECS::Service Ecs
08:45:14PM UPDATE_COMPLETE_CLEANUP_IN_PROGRESS AWS::CloudFormation::Stack development-demo-web
08:45:15PM UPDATE_COMPLETE AWS::CloudFormation::Stack development-demo-web
Stack success status: UPDATE_COMPLETE
Time took for stack deployment: 2m 13s.
Software shipped!
$

Learn More