demitas

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2021 License: MIT Imports: 11 Imported by: 0

README

demitas

Wrapper for ecspresso that creates task definitions at run time.

Usage

demitas - Wrapper for ecspresso that creates task definitions at run time.

  Flags:
       --version                      Displays the program version string.
    -h --help                         Displays help with available flag, subcommand, and positional value parameters.
       --ecspresso-cmd                ecspresso command path. (default: ecspresso)
       --ecspresso-config-src         ecspresso config source path. (default: ~/.demitas/ecspresso.yml)
       --service-def-src              ECS service definition source path. (default: ~/.demitas/ecs-service-def.jsonnet)
       --task-def-src                 ECS task definition source path. (default: ~/.demitas/ecs-task-def.jsonnet)
       --container-def-src            ECS container definition source path. (default: ~/.demitas/ecs-container-def.jsonnet)
       --ecspresso-config-overrides   JSON/YAML string that overrides ecspresso config source.
    -s --service-def-overrides        JSON/YAML string that overrides ECS service definition source.
    -t --task-def-overrides           JSON/YAML string that overrides ECS task definition source.
    -c --container-def-overrides      JSON/YAML string that overrides ECS container definition source.
    -n --print-config                 Display configs only.

  Trailing Arguments:
    Arguments after "--" is passed to "ecspresso run".
    e.g. demitas -c 'image: ...' -- --color --wait-until=running --debug
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  Environment Variables:
    DEMITAS_CONFIGS_DIR   Configuration file base directory.  (default: ~/.demitas)
    DEMITAS_PROFILE       Configuration profile directory.  (default: "")
                          If "database" is set, configs file will be read from "$DEMITAS_CONFIGS_DIR/database/..."

Installation

brew tap winebarrel/demitas
brew install demitas

Example Configurations

~/.demitas/ecspresso.yml
region: ap-northeast-1
cluster: my-cluster
service: my-service
~/.demitas/ecs-service-def.jsonnet
{
  launchType: 'FARGATE',
  networkConfiguration: {
    awsvpcConfiguration: {
      assignPublicIp: 'DISABLED',
      securityGroups: ['sg-xxx'],
      subnets: ['subnet-xxx'],
    },
  },
  enableExecuteCommand: true,
}
~/.demitas/ecs-task-def.jsonnet
{
  family: 'my-oneshot-task',
  cpu: '256',
  memory: '512',
  networkMode: 'awsvpc',
  taskRoleArn: 'arn:aws:iam::xxx:role/my-role',
  executionRoleArn: 'arn:aws:iam::xxx:role/my-exec-role',
  requiresCompatibilities: ['FARGATE'],
}
~/.demitas/ecs-container-def.jsonnet
{
  name: 'oneshot',
  cpu: 0,
  essential: true,
  logConfiguration: {
    logDriver: 'awslogs',
    options: {
      'awslogs-group': '/ecs/oneshot',
      'awslogs-region': 'ap-northeast-1',
      'awslogs-stream-prefix': 'ecs',
    },
  },
}

Execution Example

$ demitas -c '{command: [echo, hello], image: "public.ecr.aws/runecast/busybox:1.33.1"}' -- --dry-run
2021/10/10 22:33:44 my-cluster/my-service Running task
2021/10/10 22:33:44 my-cluster/my-service task definition:
{
  "containerDefinitions": [
    {
      "command": [
        "echo",
        "hello"
      ],
      "cpu": 0,
      "essential": true,
      "image": "public.ecr.aws/runecast/busybox:1.33.1",
      "logConfiguration": {
        "logDriver": "awslogs",
        "options": {
          "awslogs-group": "/ecs/busybox",
          "awslogs-region": "ap-northeast-1",
          "awslogs-stream-prefix": "ecs"
        }
      },
      "name": "oneshot"
    }
  ],
  "cpu": "256",
  "executionRoleArn": "arn:aws:iam::xxx:role/my-role",
  "family": "my-oneshot-task",
  "memory": "512",
  "networkMode": "awsvpc",
  "requiresCompatibilities": [
    "FARGATE"
  ],
  "taskRoleArn": "arn:aws:iam::xxx:role/my-exec-role",
}
2021/10/10 22:33:44 my-cluster/my-service DRY RUN OK

FAQ

Q: Will the created ECS task definitions be deleted?

A: No.

Documentation

Index

Constants

View Source
const (
	ContainerDefinitionName = "ecs-container-def.json"
)
View Source
const (
	EcspressoConfigName = "ecspresso.yml"
)
View Source
const (
	ServiceDefinitionName = "ecs-service-def.json"
)
View Source
const (
	TaskDefinitionName = "ecs-task-def.json"
)

Variables

This section is empty.

Functions

func RunTask

func RunTask(opts *RunOptions, ecsConf *EcspressoConfig, svrDef *ServiceDefinition, taskDef *TaskDefinition) (err error)

Types

type BuildOptions

type BuildOptions struct {
	EcspressoConfigSrc       string
	ServiceDefSrc            string
	TaskDefSrc               string
	ContainerDefSrc          string
	EcspressoConfigOverrides []byte
	ServiceDefOverrides      []byte
	TaskDefOverrides         []byte
	ContainerDefOverrides    []byte
}

type ContainerDefinition

type ContainerDefinition struct {
	Content []byte
}

func BuildContainerDefinition

func BuildContainerDefinition(path string, overrides []byte) (*ContainerDefinition, error)

func NewContainerDefinition

func NewContainerDefinition(path string) (*ContainerDefinition, error)

func (*ContainerDefinition) Patch

func (containerDef *ContainerDefinition) Patch(overrides []byte) error

type EcspressoConfig

type EcspressoConfig struct {
	Content []byte
}

func BuildEcspressoConfig

func BuildEcspressoConfig(path string, overrides []byte) (*EcspressoConfig, error)

func NewEcspressoConfig

func NewEcspressoConfig(path string) (*EcspressoConfig, error)

func (*EcspressoConfig) Patch

func (ecsConf *EcspressoConfig) Patch(overrides []byte) error

func (*EcspressoConfig) Print

func (ecsConf *EcspressoConfig) Print()

type RunOptions

type RunOptions struct {
	EcspressoPath    string
	EcspressoOptions []string
	PrintConfig      bool
}

type Runner

type Runner struct {
	*RunOptions
}

type ServiceDefinition

type ServiceDefinition struct {
	Content []byte
}

func BuildServiceDefinition

func BuildServiceDefinition(path string, overrides []byte) (*ServiceDefinition, error)

func NewServiceDefinition

func NewServiceDefinition(path string) (*ServiceDefinition, error)

func (*ServiceDefinition) Patch

func (svrDef *ServiceDefinition) Patch(overrides []byte) error

func (*ServiceDefinition) Print

func (svrDef *ServiceDefinition) Print()

type TaskDefinition

type TaskDefinition struct {
	Content []byte
}

func BuildTaskDefinition

func BuildTaskDefinition(path string, overrides []byte, containerDef *ContainerDefinition) (*TaskDefinition, error)

func NewTaskDefinition

func NewTaskDefinition(path string) (*TaskDefinition, error)

func (*TaskDefinition) Patch

func (taskDef *TaskDefinition) Patch(overrides []byte, containerDef *ContainerDefinition) error

func (*TaskDefinition) Print

func (taskDef *TaskDefinition) Print()

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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