ecspresso is a deployment tool for Amazon ECS
ecspresso is a deployment tool for Amazon ECS.
(pronounced the same as "espresso" :coffee:)
ecspresso allows you to manage ECS services and task definitions as code in JSON, YAML, or Jsonnet files, enabling version control and infrastructure as code practices. You can generate configuration files from existing ECS services using ecspresso init, making it easy to start managing your infrastructure.
Definition files support template syntax and Jsonnet native functions to embed environment variables, Terraform state values, SSM parameters, and Secrets Manager ARNs. ecspresso supports multiple deployment strategies including rolling updates and Blue/Green deployments with both ECS native and CodeDeploy controllers. Before deploying, you can preview changes with diff and validate configurations with verify. If something goes wrong, rollback helps you safely revert to a previous state.
ecspresso also supports ECS Express mode for simplified deployments and provides a plugin system for extending functionality.
$ brew install kayac/tap/ecspresso$ asdf plugin add ecspresso
# or
$ asdf plugin add ecspresso https://github.com/kayac/asdf-ecspresso.git
$ asdf install ecspresso 2.3.0
$ asdf set -u ecspresso 2.3.0aqua is a CLI version manager.
$ aqua g -i kayac/ecspressoDocker images are available on GitHub Container Registry.
$ docker pull ghcr.io/kayac/ecspresso:v2.7.0The image is based on gcr.io/distroless/static-debian12 and supports both linux/amd64 and linux/arm64 architectures.
$ docker run --rm \
-v ~/.aws:/root/.aws:ro \
-v $(pwd):/work \
-w /work \
ghcr.io/kayac/ecspresso:v2.7.0 deploy --config ecspresso.ymlhttps://circleci.com/orbs/registry/orb/fujiwara/ecspresso
version: 2.1
orbs:
ecspresso: fujiwara/[email protected]
jobs:
install:
steps:
- checkout
- ecspresso/install:
version: v2.3.0 # or latest
# version-file: .ecspresso-version
os: linux # or windows or darwin
arch: amd64 # or arm64
- run:
command: |
ecspresso versionversion: latest installs different versions of ecspresso for each Orb version.
Note: version: latest is not recommended as it may cause unexpected behavior when a new version of ecspresso is released.
Orb fujiwara/[email protected] supports version-file: path/to/file, which installs the ecspresso version specified in the file. This version number does not have a v prefix, For example, 2.0.0.
Action kayac/ecspresso@v2 installs an ecspresso binary for Linux(x86_64) into /usr/local/bin. This action installs ecspresso. When args input is provided, it runs ecspresso with the specified arguments after installation.
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: kayac/ecspresso@v2
with:
version: v2.3.0 # or latest
# version-file: .ecspresso-version
- run: |
ecspresso deploy --config ecspresso.ymlTo use the latest version of ecspresso, pass the parameter "latest".
- uses: kayac/ecspresso@v2
with:
version: latestversion: latest installs different versions of ecspresso for each Action version.
Note: version: latest is not recommended as it may cause unexpected behavior when a new version of ecspresso is released.
Action kayac/ecspresso@v2 supports version-file: path/to/file, which installs the ecspresso version specified in the file. This version number does not have a v prefix, For example 2.3.0.
When the args input is provided, the action runs ecspresso with the specified arguments after installation.
- uses: kayac/ecspresso@v2
with:
version: latest
args: deploy
env:
ECSPRESSO_CONFIG: ecspresso.yml…For more options for sub-commands, See ecspresso sub-command --help.
--log-format option controls the log output format. The default is text.
text format outputs human-readable logs. Attributes from slog.With (e.g. service/cluster) appear before the message, and per-call attributes appear after the message in [key:value] format.
2024-01-01T00:00:00.000+09:00 [INFO] [myService/default] deployment created on CodeDeploy [deployment_id:d-XXXXXXXXX] [url:https://...]json format outputs structured JSON logs suitable for machine parsing. All attributes are output as individual JSON fields.
{"time":"2024-01-01T00:00:00.000+09:00","level":"INFO","msg":"deployment created on CodeDeploy","cluster":"default","service":"myService","deployment_id":"d-XXXXXXXXX","url":"https://..."}ecspresso allows you to easily manage your existing/running ECS services by code.
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
2024-01-01T00:00:00.000+09:00 [INFO] [myservice/default] saving service definition [path:ecs-service-def.json]
2024-01-01T00:00:00.000+09:00 [INFO] [myservice/default] saving task definition [path:ecs-task-def.json]
2024-01-01T00:00:00.000+09:00 [INFO] [myservice/default] saving config [path:ecspresso.yml]Review the generated files: ecspresso.yml, ecs-service-def.json, and ecs-task-def.json.
Now you can deploy the service using ecspresso!
$ ecspresso deploy --config ecspresso.ymlecspresso can read service and task definition files as a template. A typical use case is to replace the image's tag in the task definition file.
Modify ecs-task-def.json as below.
- "image": "nginx:latest",
+ "image": "nginx:{{ must_env `IMAGE_TAG` }}",Then, deploy the service with environment variable IMAGE_TAG.
$ IMAGE_TAG=stable ecspresso deploy --config ecspresso.ymlFor more information, refer to the Configuration file and Template syntax sections.
A configuration file for ecspresso (YAML, JSON, or Jsonnet format).
region: ap-northeast-1 # or AWS_REGION environment variable
cluster: default
service: myservice
task_definition: taskdef.json
timeout: 5m # default 10m
ignore:
tags:
- ecspresso:ignore # ignore tags of service and task definitionecspresso deploy works as below.
task-definition file (JSON or Jsonnet).{{ env `FOO` `bar` }} syntax in the JSON file with environment variable "FOO".{{ must_env `FOO` }} syntax in the JSON file wth environment variable "FOO".service_definition file (JSON or Jsonnet).Configuration files and task/service definition files are read by go-config which provides template functions env, must_env and json_escape.
ecspresso uses the text/template standard package in Go to render template files, and parses them as YAML or JSON.
When using Jsonnet, ecspresso first renders the Jsonnet files and then parses them as text/template. As a result, template functions can only render string values using "{{ ... }}", since the template function syntax {{ }} conflicts with Jsonnet syntax. To render non-string values, consider using Jsonnet functions instead.
By default, ecspresso provides the following as template functions.
env"{{ env `NAME` `default value` }}"This replaces the placeholder with the value of the environment variable NAME. If not set, it defaults to "default value".
must_env"{{ must_env `NAME` }}"This replaces the placeholder with the value of environment variable NAME. If not set, ecspresso will panic and stop forcefully.
Defining critical values with must_env helps prevent unintended deployments by ensuring these values are set before execution.
json_escape"{{ must_env `JSON_VALUE` | json_escape }}"This escapes values as JSON strings, which is useful for embedding values as strings that require escaping, such as quotes.
ecspresso also adds some template functions via plugins. See the Plugins section.
ecspresso deploy performs rolling deployment by default.
…deploy commands has many options to customize the deployment behavior. See ecspresso deploy --help for more details.
…ecspresso deploy waits until the deployment completes by default. Use --no-wait to return immediately after starting the deployment, or --wait-until to choose what to wait for.
For the ECS deployment controller (also used when `deploymentC
No open issues yet, or sync has not completed.