Operations & Imperative Commands
While declarative configuration is preferred for managing resources, ecsctl provides powerful imperative commands for daily maintenance, debugging, and rapid deployments.
đĸ Deploying Images (deploy)
Update an existing ECS service with a new container image tag. This command triggers a rolling deployment by updating the service's task definition with the new image.
Basic Deploy
Deploy a new image to the default container in the task definition:
Specify a Container Name
If your task definition contains multiple containers, specify the target container using the --container flag:
âŠī¸ Rolling Back a Deployment (rollback)
Restore the task definition used by the most recent completed deployment before the service's current task definition:
Use ecsctl describe service my-service --cluster my-cluster to review task
definition revisions, deployment timestamps, and rollout reasons. Rollback
supports ECS rolling deployments. Services managed by CodeDeploy or an external
deployment controller must be rolled back through that controller.
đ Scaling Services (scale)
Quickly scale the running task count of an ECS service up or down.
Example
Scale the desired task count to 5:
This changes the service's desired task count. If Application Auto Scaling is also configured, its policies can change the count again as load changes.
đ Fetching Logs (logs)
Stream or fetch CloudWatch Logs events from the containers in an ECS service. The task definition must send container logs to CloudWatch Logs, and your AWS identity must be allowed to read those log events. ecsctl gathers matching logs across tasks in the service.
Tail Logs
Fetch the last 100 log lines:
Follow Logs
Stream logs in real-time to your terminal (similar to tail -f):
đģ Interactive Container Shell (exec)
Open an interactive bash/sh session or execute a single command inside a running task container using ECS Exec.
[!IMPORTANT] To use this command, install the AWS Session Manager Plugin locally and make sure ECS Exec is enabled for the task. Your AWS identity and the task's IAM role also need the permissions required by ECS Exec. See AWS ECS Exec prerequisites.
Interactive Shell
Open a shell session (defaults to /bin/sh or /bin/bash in the default container):
Specify Container and Command
Specify a particular container and command to run: