ecspresso

package module
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2017 License: MIT Imports: 13 Imported by: 0

README

ecspresso

ecspresso is a deployment tool for Amazon ECS.

(pronounced same as "espresso")

Usage

usage: ecspresso --config=CONFIG [<flags>] <command> [<args> ...]

Flags:
  --help           Show context-sensitive help (also try --help-long and --help-man).
  --config=CONFIG  config file

Commands:
  help [<command>...]
    Show help.

  deploy [<flags>]
    deploy service

  create [<flags>]
    create service

  status [<flags>]
    show status of service

  rollback [<flags>]
    rollback service
Configuration file

YAML format.

region: ap-northeast-1
cluster: default
service: myService
task_definition: myTask.json
timeout: 5m

ecspresso works as below.

  • Register a new task definition from JSON file.
    • JSON file is same format as aws ecs describe-task-definition output.
    • Replace {{ env `FOO` `bar` }} syntax in the JSON file to environment variable "FOO".
      • If "FOO" is not defined, replaced by "bar"
    • Replace {{ must_env `FOO` }} syntax in the JSON file to environment variable "FOO".
      • If "FOO" is not defined, abort immediately.
  • Update a service definition.
  • Wait a service stable.

Example of deploy

$ ecspresso deploy --config config.yaml
2017/11/09 23:20:13 myService/default Starting deploy
Service: myService
Cluster: default
TaskDefinition: myService:3
Deployments:
    PRIMARY myService:3 desired:1 pending:0 running:1
Events:
2017/11/09 23:20:13 myService/default Creating a new task definition by myTask.json
2017/11/09 23:20:13 myService/default Registering a new task definition...
2017/11/09 23:20:13 myService/default Task definition is registered myService:4
2017/11/09 23:20:13 myService/default Updating service...
2017/11/09 23:20:13 myService/default Waiting for service stable...(it will take a few minutes)
2017/11/09 23:23:23 myService/default  PRIMARY myService:4 desired:1 pending:0 running:1
2017/11/09 23:23:29 myService/default Service is stable now. Completed!

Example of create

escpresso can create service by service_definition JSON file and task_definition.

$ ecspresso create --config config.yaml
...
# config.yaml
service_definition: service.json

example of service.json below.

{
  "role": "ecsServiceRole",
  "loadBalancers": [
    {
      "containerName": "myLoadbalancer",
      "containerPort": 80,
      "targetGroupArn": "arn:aws:elasticloadbalancing:[region]:[account-id]:targetgroup/{target-name}/201ae83c14de522d"
    }
  ]
}

Keys are same format as aws ecs describe-services output.

  • deploymentConfiguration
  • launchType
  • loadBalancers
  • networkConfiguration
  • placementConstraint
  • placementStrategy
  • role

Notes

Deploy to Fargate

If you want to deploy services to Fargate, task-definition and service-definition requires some keys.

for task definition.

  • requiresCompatibilities
  • networkMode
  • cpu
  • memory
{
  "taskDefinition": {
    "networkMode": "awsvpc",
    "requiresCompatibilities": [
      "FARGATE"
    ],
    "cpu": "1024",
    "memory": "2048",
    // ...
}

for service-definition.

  • launchType
  • networkConfiguration
{
  "launchType": "FARGATE",
  "networkConfiguration": {
    "awsvpcConfiguration": {
      "subnets": [
        "subnet-aaaaaaaa",
        "subnet-bbbbbbbb"
      ],
      "securityGroups": [
        "sg-11111111"
      ],
      "assignPublicIp": "ENABLED"
    }
  },
  // ...
}

LICENCE

MIT

Author

KAYAC Inc.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App added in v0.2.2

type App struct {
	Service        string
	Cluster        string
	TaskDefinition *ecs.TaskDefinition
	Registered     *ecs.TaskDefinition
	// contains filtered or unexported fields
}

func NewApp added in v0.2.2

func NewApp(conf *Config) (*App, error)

func (*App) Create added in v0.2.2

func (d *App) Create(opt CreateOption) error

func (*App) Deploy added in v0.2.2

func (d *App) Deploy(opt DeployOption) error

func (*App) DescribeServiceDeployments added in v0.2.2

func (d *App) DescribeServiceDeployments(ctx context.Context) (int, error)

func (*App) DescribeServiceStatus added in v0.2.2

func (d *App) DescribeServiceStatus(ctx context.Context, events int) (*ecs.Service, error)

func (*App) DescribeServicesInput added in v0.2.2

func (d *App) DescribeServicesInput() *ecs.DescribeServicesInput

func (*App) FindRollbackTarget added in v0.2.2

func (d *App) FindRollbackTarget(ctx context.Context, taskDefinitionArn string) (string, error)

func (*App) LoadServiceDefinition added in v0.2.2

func (d *App) LoadServiceDefinition(path string) (*ecs.CreateServiceInput, error)

func (*App) LoadTaskDefinition added in v0.2.2

func (d *App) LoadTaskDefinition(path string) error

func (*App) Log added in v0.2.2

func (d *App) Log(v ...interface{})

func (*App) Name added in v0.2.2

func (d *App) Name() string

func (*App) RegisterTaskDefinition added in v0.2.2

func (d *App) RegisterTaskDefinition(ctx context.Context) error

func (*App) Rollback added in v0.2.2

func (d *App) Rollback(opt RollbackOption) error

func (*App) Start added in v0.2.2

func (d *App) Start() (context.Context, context.CancelFunc)

func (*App) Status added in v0.2.2

func (d *App) Status(opt StatusOption) error

func (*App) UpdateService added in v0.2.2

func (d *App) UpdateService(ctx context.Context, taskDefinitionArn string) error

func (*App) WaitServiceStable added in v0.2.2

func (d *App) WaitServiceStable(ctx context.Context) error

type Config added in v0.2.2

type Config struct {
	Region                string        `yaml:"region"`
	Service               string        `yaml:"service"`
	Cluster               string        `yaml:"cluster"`
	TaskDefinitionPath    string        `yaml:"task_definition"`
	ServiceDefinitionPath string        `yaml:"service_definition"`
	Timeout               time.Duration `yaml:"timeout"`
}

func NewDefaultConfig added in v0.2.2

func NewDefaultConfig() *Config

func (*Config) Validate added in v0.2.2

func (c *Config) Validate() error

type CreateOption added in v0.2.2

type CreateOption struct {
	DryRun *bool
}

type DeployOption added in v0.2.2

type DeployOption struct {
	DryRun *bool
}

type RollbackOption added in v0.2.2

type RollbackOption struct {
	DryRun *bool
}

type ServiceDefinition added in v0.2.2

type ServiceDefinition struct {
	DeploymentConfiguration *ecs.DeploymentConfiguration `json:"deploymentConfiguration"`
	LaunchType              *string                      `json:"launchType"`
	LoadBalancers           []*ecs.LoadBalancer          `json:"loadBalancers"`
	NetworkConfiguration    *ecs.NetworkConfiguration    `json:"networkConfiguration"`
	PlacementConstraints    []*ecs.PlacementConstraint   `json:"placementConstraints"`
	PlacementStrategy       []*ecs.PlacementStrategy     `json:"placementStrategy"`
	Role                    *string                      `json:"role"`
}

type StatusOption added in v0.2.2

type StatusOption struct {
	Events *int
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL