ecspresso

package module
v1.99.3 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2022 License: MIT Imports: 62 Imported by: 2

README

ecspresso

ecspresso is a deployment tool for Amazon ECS.

(pronounced same as "espresso")

Documents

ecspresso handbook (Japanese)

ecspresso Advent Calendar 2020 (Japanese)

Install

Homebrew (macOS and Linux)
$ brew install kayac/tap/ecspresso
Binary packages

Releases

CircleCI Orbs

https://circleci.com/orbs/registry/orb/fujiwara/ecspresso

version: 2.1
orbs:
  ecspresso: fujiwara/ecspresso@0.0.15
jobs:
  install:
    steps:
      - checkout
      - ecspresso/install:
          version: v1.6.0 # or latest
      - run:
          command: |
            ecspresso version
GitHub Actions

Action kayac/ecspresso@v1 installs ecspresso binary for Linux into /usr/local/bin. This action runs install only.

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: kayac/ecspresso@v1
        with:
          version: v1.6.0
      - run: |
          ecspresso deploy --config ecspresso.yml

Pass the parameter "latest" to use the latest version of ecspresso.

      - uses: kayac/ecspresso@v1
        with:
          version: latest

Usage

usage: ecspresso [<flags>] <command> [<args> ...]

Flags:
  --help                 Show context-sensitive help (also try --help-long and
                         --help-man).
  --config=CONFIG        config file
  --debug                enable debug log
  --envfile=ENVFILE ...  environment files
  --color                enable colored output

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

  version
    show version

  deploy [<flags>]
    deploy service

  scale [<flags>]
    scale service. equivalent to deploy --skip-task-definition
    --no-update-service

  refresh [<flags>]
    refresh service. equivalent to deploy --skip-task-definition
    --force-new-deployment --no-update-service

  create [<flags>]
    create service

  status [<flags>]
    show status of service

  rollback [<flags>]
    rollback service

  delete [<flags>]
    delete service

  run [<flags>]
    run task

  register [<flags>]
    register task definition

  wait
    wait until service stable

  init --service=SERVICE [<flags>]
    create service/task definition files by existing ECS service

  diff
    display diff for task definition compared with latest one on ECS

  appspec [<flags>]
    output AppSpec YAML for CodeDeploy to STDOUT

  verify [<flags>]
    verify resources in configurations

  render [<flags>]
    render config, service definition or task definition file to stdout

  tasks [<flags>]
    list tasks that are in a service or having the same family

  exec [<flags>]
    execute command in a task

For more options for sub-commands, See ecspresso sub-command --help.

Quick Start

ecspresso can easily manage your existing/running ECS service by codes.

Try ecspresso init for your ECS service with option --region, --cluster and --service.

$ ecspresso init --region ap-northeast-1 --cluster default --service myservice --config ecspresso.yml
2019/10/12 01:31:48 myservice/default save service definition to ecs-service-def.json
2019/10/12 01:31:48 myservice/default save task definition to ecs-task-def.json
2019/10/12 01:31:48 myservice/default save config to ecspresso.yml

Let me see the generated files ecspresso.yml, ecs-service-def.json, and ecs-task-def.json.

And then, you already can deploy the service by ecspresso!

$ ecspresso deploy --config ecspresso.yml

Configuration file

YAML format.

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

ecspresso deploy works as below.

  • Register a new task definition from JSON file.
    • JSON file is allowed in both formats as below.
      • aws ecs describe-task-definition output.
      • aws ecs register-task-definition --cli-input-json input.
    • 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 service tasks.
    • When --update-service option set, update service attributes by service definition.
  • Wait for a service to be stable.

Configuration files and task/service definition files are read by go-config. go-config has template functions env, must_env and json_escape.

Example of deployment

Rolling deployment
$ ecspresso deploy --config ecspresso.yml
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!
Blue/Green deployment (with AWS CodeDeploy)

ecspresso create can create a service having CODE_DEPLOY deployment controller. See ecs-service-def.json below.

{
  "deploymentController": {
    "type": "CODE_DEPLOY"
  },
  # ...
}

Currently, ecspresso doesn't create any resources on CodeDeploy. You must create an application and a deployment group for your ECS service on CodeDeploy in the other way.

ecspresso deploy creates a new deployment for CodeDeploy, and it continues on CodeDeploy.

$ ecspresso deploy --config ecspresso.yml --rollback-events DEPLOYMENT_FAILURE
2019/10/15 22:47:07 myService/default Starting deploy
Service: myService
Cluster: default
TaskDefinition: myService:5
TaskSets:
   PRIMARY myService:5 desired:1 pending:0 running:1
Events:
2019/10/15 22:47:08 myService/default Creating a new task definition by ecs-task-def.json
2019/10/15 22:47:08 myService/default Registering a new task definition...
2019/10/15 22:47:08 myService/default Task definition is registered myService:6
2019/10/15 22:47:08 myService/default desired count: 1
2019/10/15 22:47:09 myService/default Deployment d-XXXXXXXXX is created on CodeDeploy
2019/10/15 22:47:09 myService/default https://ap-northeast-1.console.aws.amazon.com/codesuite/codedeploy/deployments/d-XXXXXXXXX?region=ap-northeast-1

CodeDeploy appspec hooks can be defined in a config file. ecspresso creates Resources and version elements in appspec on deploy automatically.

cluster: default
service: test
service_definition: ecs-service-def.json
task_definition: ecs-task-def.json
appspec:
  Hooks:
    - BeforeInstall: "LambdaFunctionToValidateBeforeInstall"
    - AfterInstall: "LambdaFunctionToValidateAfterTraffic"
    - AfterAllowTestTraffic: "LambdaFunctionToValidateAfterTestTrafficStarts"
    - BeforeAllowTraffic: "LambdaFunctionToValidateBeforeAllowingProductionTraffic"
    - AfterAllowTraffic: "LambdaFunctionToValidateAfterAllowingProductionTraffic"

Scale out/in

To change a desired count of the service, specify scale --tasks.

$ ecspresso scale --config ecspresso.yml --tasks 10

scale command is equivalent to deploy --skip-task-definition --no-update-service.

Example of create

escpresso can create a service by service_definition JSON file and task_definition.

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

example of service.json below.

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

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

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

Example of run task

$ ecspresso run --config ecspresso.yml --task-def=db-migrate.json

When --task-def is not set, use a task definition included in a service.

Other options for RunTask API are set by service attributes(CapacityProviderStrategy, LaunchType, PlacementConstraints, PlacementStrategy and PlatformVersion).

Notes

Use Jsonnet instead of JSON

ecspresso v1.7 or later can use Jsonnet file format for service and task definition.

If the file extension is .jsonnet, ecspresso will process Jsonnet first, convert it to JSON, and then load it.

service_definition: ecs-service-def.jsonnet
task_definition: ecs-task-def.jsonnet

ecspresso includes github.com/google/go-jsonnet as a library, we don't need the jsonnet command.

--ext-str and --ext-code flag sets Jsonnet External Variables.

$ ecspresso --ext-str Foo=foo --ext-code "Bar=1+1" ...
{
  foo: std.extVar('Foo'), // = "foo"
  bar: std.extVar('Bar'), // = 2
}

Deploy to Fargate

If you want to deploy services to Fargate, task definitions and service definitions require some settings.

For task definitions,

  • requiresCompatibilities (required "FARGATE")
  • networkMode (required "awsvpc")
  • cpu (required)
  • memory (required)
  • executionRoleArn (optional)
{
  "taskDefinition": {
    "networkMode": "awsvpc",
    "requiresCompatibilities": [
      "FARGATE"
    ],
    "cpu": "1024",
    "memory": "2048",
    // ...
}

For service-definition,

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

Fargate Spot support

  1. Set capacityProviders and defaultCapacityProviderStrategy to ECS cluster.
  2. If you hope to migrate existing service to use Fargate Spot, define capacityProviderStrategy into service definition as below. ecspresso deploy --update-service applies the settings to the service.
{
  "capacityProviderStrategy": [
    {
      "base": 1,
      "capacityProvider": "FARGATE",
      "weight": 1
    },
    {
      "base": 0,
      "capacityProvider": "FARGATE_SPOT",
      "weight": 1
    }
  ],
  # ...

How to check diff and verify service/task definitions before deploy.

ecspresso supports diff and verify subcommands.

diff

Shows differences between local task/service definitions and remote (on ECS) definitions.

$ ecspresso --config ecspresso.yml diff
--- arn:aws:ecs:ap-northeast-1:123456789012:service/ecspresso-test/nginx-local
+++ ecs-service-def.json
@@ -38,5 +38,5 @@
   },
   "placementConstraints": [],
   "placementStrategy": [],
-  "platformVersion": "1.3.0"
+  "platformVersion": "LATEST"
 }
 
--- arn:aws:ecs:ap-northeast-1:123456789012:task-definition/ecspresso-test:202
+++ ecs-task-def.json
@@ -1,6 +1,10 @@
 {
   "containerDefinitions": [
     {
       "cpu": 0,
       "environment": [],
       "essential": true,
-      "image": "nginx:latest",
+      "image": "nginx:alpine",
       "logConfiguration": {
         "logDriver": "awslogs",
         "options": {
verify

Verify resources related with service/task definitions.

For example,

  • An ECS cluster exists.
  • The target groups in service definitions match the container name and port defined in the definitions.
  • A task role and a task execution role exist and can be assumed by ecs-tasks.amazonaws.com.
  • Container images exist at the URL defined in task definitions. (Checks only for ECR or DockerHub public images.)
  • Secrets in task definitions exist and be readable.
  • Can create log streams, can put messages to the streams in specified CloudWatch log groups.

ecspresso verify tries to assume the task execution role defined in task definitions to verify these items. If failed to assume the role, it continues to verify with the current sessions.

$ ecspresso --config ecspresso.yml verify
2020/12/08 11:43:10 nginx-local/ecspresso-test Starting verify
  TaskDefinition
    ExecutionRole[arn:aws:iam::123456789012:role/ecsTaskRole]
    --> [OK]
    TaskRole[arn:aws:iam::123456789012:role/ecsTaskRole]
    --> [OK]
    ContainerDefinition[nginx]
      Image[nginx:alpine]
      --> [OK]
      LogConfiguration[awslogs]
      --> [OK]
    --> [OK]
  --> [OK]
  ServiceDefinition
  --> [OK]
  Cluster
  --> [OK]
2020/12/08 11:43:14 nginx-local/ecspresso-test Verify OK!
tasks

task command lists tasks run by a service or having the same family to a task definition.

Flags:
  --id=""                task ID
  --output=table         output format (table|json|tsv)
  --find                 find a task from tasks list and dump it as JSON
  --stop                 stop a task
  --force                stop a task without confirmation prompt

When --find option is set, you can select a task in a list of tasks and show the task as JSON.

filter_command in ecspresso.yml can define a command to filter tasks. For example peco, fzf and etc.

filter_command: peco

When --stop option is set, you can select a task in a list of tasks and stop the task.

exec

exec command executes a command on task.

session-manager-plugin is required in PATH.

Flags:
  --id=""                task ID
  --command="sh"         command
  --container=CONTAINER  container name

If --id is not set, the command shows a list of tasks to select a task to execute.

filter_command in ecspresso.yml works the same as tasks command.

See also the official document Using Amazon ECS Exec for debugging.

port forwarding

ecspresso exec --port-forward forwards local port to ECS tasks port.

$ ecspresso exec --port-forward --port 80 --local-port 8080
...

If --id is not set, the command shows a list of tasks to select a task to forward port.

When --local-port is not specified, use the ephemeral port for local port.

suspend / resume application auto scaling

ecspresso deploy and scale can suspend / resume application auto scaling.

--suspend-auto-scaling sets suspended state true. --resume-auto-scaling sets suspended state false.

When you want to change the suspended state simply, try ecspresso scale --suspend-auto-scaling or ecspresso scale --resume-auto-scaling. That operation will change suspended state only.

Plugins

tfstate

tfstate plugin introduces a template function tfstate.

ecspresso.yml

region: ap-northeast-1
cluster: default
service: test
service_definition: ecs-service-def.json
task_definition: ecs-task-def.json
plugins:
  - name: tfstate
    config:
      path: terraform.tfstate    # path to tfstate file
      # or url: s3://my-bucket/terraform.tfstate

ecs-service-def.json

{
  "networkConfiguration": {
    "awsvpcConfiguration": {
      "subnets": [
        "{{ tfstatef `aws_subnet.private['%s'].id` `az-a` }}"
      ],
      "securityGroups": [
        "{{ tfstate `data.aws_security_group.default.id` }}"
      ]
    }
  }
}

{{ tfstate "resource_type.resource_name.attr" }} will expand to an attribute value of the resource in tfstate.

{{ tfstatef "resource_type.resource_name['%s'].attr" "index" }} is similar to {{ tfstatef "resource_type.resource_name['index'].attr" }}. This function is useful to build a resource address with environment variables.

{{ tfstatef `aws_subnet.ecs['%s'].id` (must_env `SERVICE`) }}

cloudformation

cloudformation plugin introduces template functions cfn_output and cfn_export.

An example of CloudFormation stack template defines Outputs and Exports.

# StackName: ECS-ecspresso
Outputs:
  SubnetAz1:
    Value: !Ref PublicSubnetAz1
  SubnetAz2:
    Value: !Ref PublicSubnetAz2
  EcsSecurityGroupId:
    Value: !Ref EcsSecurityGroup
    Export:
      Name: !Sub ${AWS::StackName}-EcsSecurityGroupId

Load cloudformation plugin in a config file.

ecspresso.yml

# ...
plugins:
  - name: cloudformation

cfn_output StackName OutputKey lookups OutputValue of OutputKey in the StackName. cfn_export ExportName lookups exported value by name.

ecs-service-def.json

{
  "networkConfiguration": {
    "awsvpcConfiguration": {
      "subnets": [
        "{{ cfn_output `ECS-ecspresso` `SubnetAz1` }}",
        "{{ cfn_output `ECS-ecspresso` `SubnetAz2` }}"
      ],
      "securityGroups": [
        "{{ cfn_export `ECS-ecspresso-EcsSecurityGroupId` }}"
      ]
    }
  }
}

LICENCE

MIT

Author

KAYAC Inc.

Documentation

Index

Constants

View Source
const (
	DefaultClusterName = "default"
	DefaultTimeout     = 10 * time.Minute
)
View Source
const (
	CodeDeployConsoleURLFmt = "https://%s.console.aws.amazon.com/codesuite/codedeploy/deployments/%s?region=%s"
)
View Source
const DefaultConfigFilePath = "ecspresso.yml"
View Source
const DefaultDesiredCount = -1

Variables

View Source
var CreateFileMode = os.FileMode(0644)
View Source
var Version string

Functions

func CLI added in v1.99.1

func CLI(ctx context.Context, parse CLIParseFunc) (int, error)

func ExportEnvFile added in v1.4.0

func ExportEnvFile(file string) error

ExportEnvFile exports envfile to environment variables.

func Log added in v1.99.0

func Log(f string, v ...interface{})

func MarshalJSONForAPI added in v1.99.0

func MarshalJSONForAPI(v interface{}) ([]byte, error)

func MustMarshalJSONStringForAPI added in v1.99.1

func MustMarshalJSONStringForAPI(v interface{}) string

func NormalizePlatform added in v1.99.0

func NormalizePlatform(p *types.RuntimePlatform, isFargate bool) (arch, os string)

Types

type App added in v0.0.2

type App struct {
	Service string
	Cluster string
	// contains filtered or unexported fields
}

func New added in v1.99.0

func New(ctx context.Context, opt *Option) (*App, error)

func (*App) AppSpec added in v0.99.7

func (d *App) AppSpec(ctx context.Context, opt AppSpecOption) error

func (*App) Config added in v1.99.1

func (d *App) Config() *Config

func (*App) Delete added in v0.4.0

func (d *App) Delete(ctx context.Context, opt DeleteOption) error

func (*App) Deploy added in v0.1.0

func (d *App) Deploy(ctx context.Context, opt DeployOption) error

func (*App) DeployByCodeDeploy added in v0.12.0

func (d *App) DeployByCodeDeploy(ctx context.Context, taskDefinitionArn string, count *int32, sv *Service, opt DeployOption) error

func (*App) Deregister added in v1.7.0

func (d *App) Deregister(ctx context.Context, opt DeregisterOption) error

func (*App) DescribeService added in v0.16.0

func (d *App) DescribeService(ctx context.Context) (*Service, error)

func (*App) DescribeServiceStatus added in v0.1.0

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

func (*App) DescribeServicesInput added in v0.0.2

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

func (*App) DescribeTaskDefinition added in v0.8.1

func (d *App) DescribeTaskDefinition(ctx context.Context, tdArn string) (*TaskDefinitionInput, error)

func (*App) DescribeTaskStatus added in v0.15.0

func (d *App) DescribeTaskStatus(ctx context.Context, task *types.Task, watchContainer *types.ContainerDefinition) error

func (*App) DescribeTasksInput added in v0.5.0

func (d *App) DescribeTasksInput(task *types.Task) *ecs.DescribeTasksInput

func (*App) Diff added in v0.16.0

func (d *App) Diff(ctx context.Context, opt DiffOption) error

func (*App) Exec added in v1.5.0

func (d *App) Exec(ctx context.Context, opt ExecOption) error

func (*App) FindRollbackTarget added in v0.1.0

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

func (*App) GetLogEvents added in v0.5.0

func (d *App) GetLogEvents(ctx context.Context, logGroup string, logStream string, startedAt time.Time, nextToken *string) (*string, error)

func (*App) GetLogEventsInput added in v0.5.0

func (d *App) GetLogEventsInput(logGroup string, logStream string, startAt int64, nextToken *string) *cloudwatchlogs.GetLogEventsInput

func (*App) GetLogInfo added in v0.5.0

func (d *App) GetLogInfo(task *types.Task, c *types.ContainerDefinition) (string, string)

func (*App) Init added in v0.11.0

func (d *App) Init(ctx context.Context, opt InitOption) error

func (*App) LoadServiceDefinition added in v0.2.0

func (d *App) LoadServiceDefinition(path string) (*Service, error)

func (*App) LoadTaskDefinition added in v0.0.2

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

func (*App) Log added in v0.0.2

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

func (*App) LogJSON added in v0.16.0

func (d *App) LogJSON(v interface{})

func (*App) Name added in v0.0.2

func (d *App) Name() string

func (*App) NewEcsta added in v1.99.0

func (d *App) NewEcsta(ctx context.Context) (*ecsta.Ecsta, error)

func (*App) Register added in v0.10.0

func (d *App) Register(ctx context.Context, opt RegisterOption) error

func (*App) RegisterTaskDefinition added in v0.0.2

func (d *App) RegisterTaskDefinition(ctx context.Context, td *TaskDefinitionInput) (*TaskDefinition, error)

func (*App) Render added in v1.2.0

func (d *App) Render(ctx context.Context, opt RenderOption) error

func (*App) Revesions added in v1.7.0

func (d *App) Revesions(ctx context.Context, opt RevisionsOption) error

func (*App) Rollback added in v0.1.0

func (d *App) Rollback(ctx context.Context, opt RollbackOption) error

func (*App) RollbackByCodeDeploy added in v1.5.0

func (d *App) RollbackByCodeDeploy(ctx context.Context, sv *Service, tdArn string, opt RollbackOption) error

func (*App) Run added in v0.5.0

func (d *App) Run(ctx context.Context, opt RunOption) error

func (*App) RunTask added in v0.5.0

func (d *App) RunTask(ctx context.Context, tdArn string, ov *types.TaskOverride, opt *RunOption) (*types.Task, error)

func (*App) Start added in v0.1.0

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

func (*App) Status added in v0.1.0

func (d *App) Status(ctx context.Context, opt StatusOption) error

func (*App) Tasks added in v1.5.0

func (d *App) Tasks(ctx context.Context, opt TasksOption) error

func (*App) Timeout added in v1.99.1

func (d *App) Timeout() time.Duration

func (*App) UnmarshalJSONForStruct added in v1.99.0

func (d *App) UnmarshalJSONForStruct(src []byte, v interface{}, path string) error

func (*App) UpdateServiceAttributes added in v0.13.3

func (d *App) UpdateServiceAttributes(ctx context.Context, sv *Service, taskDefinitionArn string, opt DeployOption) error

func (*App) UpdateServiceTasks added in v0.13.3

func (d *App) UpdateServiceTasks(ctx context.Context, taskDefinitionArn string, count *int32, sv *Service, opt DeployOption) error

func (*App) Verify added in v1.2.0

func (d *App) Verify(ctx context.Context, opt VerifyOption) error

Verify verifies service / task definitions related resources are valid.

func (*App) Wait added in v0.9.0

func (d *App) Wait(ctx context.Context, opt WaitOption) error

func (*App) WaitForCodeDeploy added in v0.99.1

func (d *App) WaitForCodeDeploy(ctx context.Context, sv *Service) error

func (*App) WaitRunTask added in v0.5.0

func (d *App) WaitRunTask(ctx context.Context, task *types.Task, watchContainer *types.ContainerDefinition, startedAt time.Time, untilRunning bool) error

func (*App) WaitServiceStable added in v0.0.2

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

type AppSpecOption added in v0.99.7

type AppSpecOption struct {
	TaskDefinition *string `help:"use task definition arn in AppSpec (latest, current or Arn)" default:"latest"`
	UpdateService  *bool   `help:"update service definition with task definition arn" default:"true" negatable:""`
}

type CLIOptions added in v1.99.1

type CLIOptions struct {
	Envfile []string          `help:"environment files"`
	Debug   bool              `help:"enable debug log"`
	ExtStr  map[string]string `help:"external string values for Jsonnet"`
	ExtCode map[string]string `help:"external code values for Jsonnet"`
	Config  string            `help:"config file" default:"ecspresso.yml"`

	Option *Option

	Appspec    *AppSpecOption    `cmd:"" help:"output AppSpec YAML for CodeDeploy to STDOUT"`
	Delete     *DeleteOption     `cmd:"" help:"delete service"`
	Deploy     *DeployOption     `cmd:"" help:"deploy service"`
	Deregister *DeregisterOption `cmd:"" help:"deregister task definition"`
	Diff       *DiffOption       `cmd:"" help:"show diff between task definition, service definition with current running service and task definition"`
	Exec       *ExecOption       `cmd:"" help:"execute command on task"`
	Init       *InitOption       `cmd:"" help:"create configuration files from existing ECS service"`
	Refresh    *RefreshOption    `cmd:"" help:"refresh service. equivalent to deploy --skip-task-definition --force-new-deployment --no-update-service"`
	Register   *RegisterOption   `cmd:"" help:"register task definition"`
	Render     *RenderOption     `cmd:"" help:"render config, service definition or task definition file to STDOUT"`
	Revisions  *RevisionsOption  `cmd:"" help:"show revisions of task definitions"`
	Rollback   *RollbackOption   `cmd:"" help:"rollback service"`
	Run        *RunOption        `cmd:"" help:"run task"`
	Scale      *ScaleOption      `cmd:"" help:"scale service. equivalent to deploy --skip-task-definition --no-update-service"`
	Status     *StatusOption     `cmd:"" help:"show status of service"`
	Tasks      *TasksOption      `cmd:"" help:"list tasks that are in a service or having the same family"`
	Verify     *VerifyOption     `cmd:"" help:"verify resources in configurations"`
	Wait       *WaitOption       `cmd:"" help:"wait until service stable"`
	Version    struct{}          `cmd:"" help:"show version"`
}

func ParseCLI added in v1.99.1

func ParseCLI(args []string) (string, *CLIOptions, error)

func ParseCLIv2 added in v1.99.1

func ParseCLIv2(args []string) (string, *CLIOptions, error)

func (*CLIOptions) ForSubCommand added in v1.99.1

func (opts *CLIOptions) ForSubCommand(sub string) interface{}

type CLIParseFunc added in v1.99.1

type CLIParseFunc func([]string) (string, *CLIOptions, error)

type Config added in v0.0.2

type Config struct {
	RequiredVersion       string           `yaml:"required_version,omitempty" json:"required_version,omitempty"`
	Region                string           `yaml:"region" json:"region"`
	Cluster               string           `yaml:"cluster" json:"cluster"`
	Service               string           `yaml:"service" json:"service"`
	ServiceDefinitionPath string           `yaml:"service_definition" json:"service_definition"`
	TaskDefinitionPath    string           `yaml:"task_definition" json:"task_definition"`
	Plugins               []ConfigPlugin   `yaml:"plugins,omitempty" json:"plugins,omitempty"`
	AppSpec               *appspec.AppSpec `yaml:"appspec,omitempty" json:"appspec,omitempty"`
	FilterCommand         string           `yaml:"filter_command,omitempty" json:"filter_command,omitempty"`
	Timeout               *Duration        `yaml:"timeout,omitempty" json:"timeout,omitempty"`
	// contains filtered or unexported fields
}

Config represents a configuration.

func NewDefaultConfig added in v0.1.0

func NewDefaultConfig() *Config

NewDefaultConfig creates a default configuration.

func (*Config) Restrict added in v0.99.0

func (c *Config) Restrict(ctx context.Context) error

Restrict restricts a configuration.

func (*Config) ValidateVersion added in v1.3.0

func (c *Config) ValidateVersion(version string) error

ValidateVersion validates a version satisfies required_version.

type ConfigPlugin added in v0.14.0

type ConfigPlugin struct {
	Name       string                 `yaml:"name"`
	Config     map[string]interface{} `yaml:"config"`
	FuncPrefix string                 `yaml:"func_prefix"`
}

func (ConfigPlugin) AppendFuncMap added in v1.99.0

func (p ConfigPlugin) AppendFuncMap(c *Config, funcMap template.FuncMap) error

func (ConfigPlugin) Setup added in v0.14.0

func (p ConfigPlugin) Setup(ctx context.Context, c *Config) error

type DeleteOption added in v0.4.0

type DeleteOption struct {
	DryRun *bool `help:"dry-run" default:"false"`
	Force  *bool `help:"delete without confirmation" default:"false"`
}

func (DeleteOption) DryRunString added in v0.13.3

func (opt DeleteOption) DryRunString() string

type DeployOption added in v0.2.0

type DeployOption struct {
	DryRun               *bool   `help:"dry run" default:"false"`
	DesiredCount         *int32  `name:"tasks" help:"desired count of tasks" default:"-1"`
	SkipTaskDefinition   *bool   `help:"skip register a new task definition" default:"false"`
	ForceNewDeployment   *bool   `help:"force a new deployment of the service" default:"false"`
	NoWait               *bool   `help:"exit ecspresso immediately after just deployed without waiting for service stable" default:"false"`
	SuspendAutoScaling   *bool   `help:"suspend application auto-scaling attached with the ECS service"`
	ResumeAutoScaling    *bool   `help:"resume application auto-scaling attached with the ECS service"`
	RollbackEvents       *string `` /* 152-byte string literal not displayed */
	UpdateService        *bool   `help:"update service attributes by service definition" default:"true" negatable:""`
	LatestTaskDefinition *bool   `help:"deploy with the latest task definition without registering a new task definition" default:"false"`
}

func (DeployOption) DryRunString added in v0.13.3

func (opt DeployOption) DryRunString() string

type DeregisterOption added in v1.7.0

type DeregisterOption struct {
	DryRun   *bool  `help:"dry run" default:"false"`
	Keeps    *int   `help:"number of task definitions to keep except in-use" default:"0"`
	Revision *int64 `help:"task definition revision to deregister" default:"0"`
	Force    *bool  `help:"force deregister without confirmation" default:"false"`
}

func (DeregisterOption) DryRunString added in v1.7.0

func (opt DeregisterOption) DryRunString() string

type DiffOption added in v0.16.0

type DiffOption struct {
	Unified *bool `help:"unified diff format" default:"true" negatable:""`
}

type Duration added in v1.99.1

type Duration struct {
	time.Duration
}

func (*Duration) MarshalJSON added in v1.99.1

func (d *Duration) MarshalJSON() ([]byte, error)

func (*Duration) MarshalYAML added in v1.99.1

func (d *Duration) MarshalYAML() ([]byte, error)

func (*Duration) UnmarshalJSON added in v1.99.1

func (d *Duration) UnmarshalJSON(b []byte) error

func (*Duration) UnmarshalYAML added in v1.99.1

func (d *Duration) UnmarshalYAML(b []byte) error

type ErrNotFound added in v1.99.1

type ErrNotFound string

func (ErrNotFound) Error added in v1.99.1

func (e ErrNotFound) Error() string

type ErrSkipVerify added in v1.99.1

type ErrSkipVerify string

func (ErrSkipVerify) Error added in v1.99.1

func (e ErrSkipVerify) Error() string

type ExecOption added in v1.5.0

type ExecOption struct {
	ID        *string `help:"task ID" default:""`
	Command   *string `help:"command to execute" default:"sh"`
	Container *string `help:"container name" default:""`

	PortForward *bool   `help:"enable port forward" default:"false"`
	LocalPort   *int    `help:"local port number" default:"0"`
	Port        *int    `help:"remote port number (required for --port-forward)" default:"0"`
	Host        *string `help:"remote host (required for --port-forward)" default:""`
}

type InitOption added in v0.11.0

type InitOption struct {
	Region                *string `help:"AWS region" env:"AWS_REGION" default:""`
	Cluster               *string `help:"ECS cluster name" default:"default"`
	Service               *string `help:"ECS service name" default:"" required:""`
	TaskDefinitionPath    *string `help:"path to output task definition file" default:"ecs-task-def.json"`
	ServiceDefinitionPath *string `help:"path to output service definition file" default:"ecs-service-def.json"`
	ConfigFilePath        *string
	ForceOverwrite        *bool `help:"overwrite existing files" default:"false"`
	Jsonnet               *bool `help:"output files as jsonnet format" default:"false"`
}

func (*InitOption) NewConfig added in v1.99.1

func (opt *InitOption) NewConfig(ctx context.Context) (*Config, error)

type Option added in v1.99.0

type Option struct {
	InitOption     *InitOption
	ConfigFilePath string
	Debug          bool
	ExtStr         map[string]string
	ExtCode        map[string]string
}

type RefreshOption added in v1.99.1

type RefreshOption struct {
	DryRun *bool `help:"dry run" default:"false"`
	NoWait *bool `help:"exit ecspresso immediately after just deployed without waiting for service stable" default:"false"`
}

func (*RefreshOption) DeployOption added in v1.99.1

func (o *RefreshOption) DeployOption() DeployOption

type RegisterOption added in v0.10.0

type RegisterOption struct {
	DryRun *bool `help:"dry run" default:"false"`
	Output *bool `help:"output the registered task definition as JSON" default:"false"`
}

func (RegisterOption) DryRunString added in v0.13.3

func (opt RegisterOption) DryRunString() string

type RenderOption added in v1.2.0

type RenderOption struct {
	Targets *[]string `` /* 165-byte string literal not displayed */
	Jsonnet *bool     `help:"render as jsonnet format" default:"false"`
}

type RevisionsOption added in v1.7.0

type RevisionsOption struct {
	Revision *int64  `help:"revision number to output" default:"0"`
	Output   *string `help:"output format (json, table, tsv)" default:"table" enum:"json,table,tsv"`
}

type RollbackOption added in v0.2.0

type RollbackOption struct {
	DryRun                   *bool   `help:"dry run" default:"false"`
	DeregisterTaskDefinition *bool   `help:"deregister the rolled-back task definition. not works with --no-wait" default:"true" negatable:""`
	NoWait                   *bool   `help:"don't wait for the service stable" default:"false"`
	RollbackEvents           *string `` /* 152-byte string literal not displayed */
}

func (RollbackOption) DryRunString added in v0.13.3

func (opt RollbackOption) DryRunString() string

type RunOption added in v0.5.0

type RunOption struct {
	DryRun               *bool   `help:"dry run" default:"false"`
	TaskDefinition       *string `name:"task-def" help:"task definition file for run task" default:""`
	NoWait               *bool   `help:"don't wait for task to complete" default:"false"`
	TaskOverrideStr      *string `name:"overrides" help:"task override JSON string" default:""`
	TaskOverrideFile     *string `name:"overrides-file" help:"task override JSON file path" default:""`
	SkipTaskDefinition   *bool   `help:"skip register a new task definition" default:"false"`
	Count                *int32  `help:"number of tasks to run (max 10)" default:"1"`
	WatchContainer       *string `help:"container name for watching exit code" default:""`
	LatestTaskDefinition *bool   `help:"use the latest task definition without registering a new task definition" default:"false"`
	PropagateTags        *string `help:"propagate the tags for the task (SERVICE or TASK_DEFINITION)" default:""`
	Tags                 *string `help:"tags for the task: format is KeyFoo=ValueFoo,KeyBar=ValueBar" default:""`
	WaitUntil            *string `help:"wait until invoked tasks status reached to (running or stopped)" default:"stopped" enum:"running,stopped"`
	Revision             *int64  `help:"revision of the task definition to run when --skip-task-definition" default:"0"`
}

func (RunOption) DryRunString added in v0.13.3

func (opt RunOption) DryRunString() string

type ScaleOption added in v1.99.1

type ScaleOption struct {
	DryRun             *bool  `help:"dry run" default:"false"`
	DesiredCount       *int32 `name:"tasks" help:"desired count of tasks" default:"-1"`
	NoWait             *bool  `help:"exit ecspresso immediately after just deployed without waiting for service stable" default:"false"`
	SuspendAutoScaling *bool  `help:"suspend application auto-scaling attached with the ECS service"`
	ResumeAutoScaling  *bool  `help:"resume application auto-scaling attached with the ECS service"`
}

func (*ScaleOption) DeployOption added in v1.99.1

func (o *ScaleOption) DeployOption() DeployOption

type Service added in v1.99.0

type Service struct {
	types.Service
	DesiredCount *int32
}

type StatusOption added in v0.2.0

type StatusOption struct {
	Events *int `help:"show events num" default:"2"`
}

type TaskDefinition

type TaskDefinition = types.TaskDefinition

type TaskDefinitionInput added in v1.5.0

type TaskDefinitionInput = ecs.RegisterTaskDefinitionInput

type TasksOption added in v1.5.0

type TasksOption struct {
	ID     *string `help:"task ID" default:""`
	Output *string `help:"output format" default:"table" enum:"table,json,tsv" default:"table"`
	Find   *bool   `help:"find a task from tasks list and dump it as JSON" default:"false"`
	Stop   *bool   `help:"stop the task" default:"false"`
	Force  *bool   `help:"stop the task without confirmation" default:"false"`
	Trace  *bool   `help:"trace the task" default:"false"`
}

type VerifyOption added in v1.2.0

type VerifyOption struct {
	GetSecrets *bool `help:"get secrets from ParameterStore or SecretsManager" default:"true" negatable:""`
	PutLogs    *bool `help:"put logs to CloudWatchLogs" default:"true" negatable:""`
}

VerifyOption represents options for Verify()

type WaitOption added in v0.9.0

type WaitOption struct {
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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