Giter Club home page Giter Club logo

ecs-goploy's Introduction

ecs-goploy

Build Status GitHub release GoDoc

ecs-goploy is a re-implementation of ecs-deploy in Golang.

This is a command line tool, but you can use deploy as a package. So when you write own deploy script for AWS ECS, you can embed deploy package in your golang source code and customize deploy recipe. Please check godoc.

Install

Get binary from github:

$ wget https://github.com/h3poteto/ecs-goploy/releases/download/v0.5.0/ecs-goploy_v0.5.0_linux_amd64.zip
$ unzip ecs-goploy_v0.5.0_linux_amd64.zip
$ ./ecs-goploy --help

Usage

$ ./ecs-goploy --help
Deploy commands for ECS

Usage:
  ecs-goploy [command]

Available Commands:
  help        Help about any command
  run         Run command
  update      Update some ECS resource
  version     Print the version number

Flags:
  -h, --help             help for ecs-goploy
      --profile string   AWS profile (detault is none, and use environment variables)
      --region string    AWS region (default is none, and use AWS_DEFAULT_REGION)
  -v, --verbose          Enable verbose mode

Use "ecs-goploy [command] --help" for more information about a command.

Deploy an ECS Service

Please specify cluser, service name and image(family:revision).

$ ./ecs-goploy update service --cluster my-cluster --service-name my-service --image nginx:stable --skip-check-deployments --enable-rollback

If you specify --base-task-definition, ecs-goploy updates the task definition with the image and deploy ecs service. If you does not specify --base-task-definition, ecs-goploy get current task definition of the service, and update with the image, and deploy ecs service.

Run Task

At first, you must update the task definition which is used to run ecs task. After that, you can run ecs task.

$ NEW_TASK_DEFINITION=`./ecs-goploy update task-definition --base-task-definition my-task-definition:1 --image nginx:stable`
$ ./ecs-goploy run task --cluster my-cluster --container-name web --task-definition $NEW_TASK_DEFINITION --command "some commands"

Update Scheduled Task

At first, you must update the task definition which is used to run scheduled task. After that, you can update the scheduled task.

$ NEW_TASK_DEFINITION=`./ecs-goploy update task-definition --base-task-definition my-task-definition:1 --image nginx:stable`
$ ./ecs-goploy update scheduled-task --count 1 --name schedule-name --task-definition $NEW_TASK_DEFINITION

Configuration

AWS Configuration

ecs-goploy calls AWS API via aws-skd-go, so you need export environment variables:

$ export AWS_ACCESS_KEY_ID=XXXXX
$ export AWS_SECRET_ACCESS_KEY=XXXXX
$ export AWS_DEFAULT_REGION=XXXXX

or set your credentials in $HOME/.aws/credentials:

[default]
aws_access_key_id = XXXXX
aws_secret_access_key = XXXXX

or prepare IAM Role or IAM Task Role.

AWS region can be set command argument: --region.

AWS IAM Policy

Below is a basic IAM Policy required for ecs-goploy.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "AllowUserToECSDeploy",
      "Effect": "Allow",
      "Action": [
        "ecr:DescribeRepositories",
        "ecr:DescribeImages",
        "ecs:DescribeServices",
        "ecs:DescribeTaskDefinition",
        "ecs:RegisterTaskDefinition",
        "ecs:UpdateService",
        "ecs:RunTask",
        "ecs:DescribeTasks",
        "ecs:ListTasks",
        "events:DescribeRule",
        "events:ListTargetsByRule",
        "events:PutTargets",
        "iam:PassRole"
      ],
      "Resource": "*"
    }
  ]
}

License

The package is available as open source under the terms of the MIT License.

ecs-goploy's People

Contributors

atijust avatar dependabot-preview[bot] avatar h3poteto avatar holidayworking avatar minamijoyo avatar suusan2go avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ecs-goploy's Issues

Dependabot can't resolve your Go dependency files

Dependabot can't resolve your Go dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

github.com/h3poteto/ecs-goploy/cmd: cannot find module providing package github.com/h3poteto/ecs-goploy/cmd

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Ignored linuxParameters after service update

Hi! Thank you for developing such a great tool.

However, after switching from using tini in our containers to embedded initProcessEnabled docker parameter I have discovered the following issue:

after updating any ECS service with ecs-goploy (and ecs-deploy too) linuxParameters section of task definition (which contains the needed initProcessEnabled parameter) is set to null. See example below.

before ecs-goploy:

"linuxParameters": {
        "capabilities": null,
        "sharedMemorySize": null,
        "tmpfs": null,
        "devices": null,
        "initProcessEnabled": true
      }

after updating the service:

"linuxParameters": null

First deployment

Now, ecs-goploy can deploy only running service, because it is using the number of active tasks for judgement. So the first deployment is failed.

Add option to monitor only first task

If I set maximum percent to 100%, ECS tasks are rolling updated. When rolling updated, deploy time is long, and I don't monitor to end of deploy. I think that it is enough to monitor first task.

Divide registration of new task from run task command

I want to update ECS Scheduled Task with new task definition which is same as migration task.
So, I want to divide these.

For example:

NEW_TASK_DEFINITION=`ecs-goploy task-definition new --base-task-definition=hogehoge:1 --image=ecs_image:revision`
ecs-goploy task --task-definition=${NEW_TASK_DEFINITION}...`

A command containing quotes can not be split properly

In ECS, we can inject environment variables from the SSM parameter store by the docker ENTRYPOINT. So, I want to delay evaluate the environment variables in command arguments.

$ ecs-goploy  --command='/bin/sh -c "echo $DATABASE_URL"'

However, the current implementation simply splits command by space.

https://github.com/crowdworks/ecs-goploy/blob/e3326d2706411e598db5be91a42a2c1a192c777d/deploy/task.go#L63

It would be great if the command can be split the string containing quotes properly.

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.