Infrastructure
RunECS: Effortlessly Execute One-Off Tasks and Database Migrations in Your ECS Cluster.
brew tap meap/runecs
brew install runecs
The easiest way to get started with runecs using Docker is by running this command.
docker run \
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
-e AWS_REGION=$AWS_REGION \
preichl/runecs list
Note: You have to pass the environment variables with AWS credentials. I recommend using direnv which I mentioned in the introduction post.
Download the binary file for your platform, see releases.
RunECS executes the command using the specified service. The service must be specified in cluster/service
format. Further, you must specify the environment variables that determine access to AWS.
export AWS_ACCESS_KEY_ID=xxxxxx
export AWS_SECRET_ACCESS_KEY=xxxxxxx
export AWS_REGION=eu-east1
runecs rake orders:upload[14021] --service my-cluster/my-service -w
Executes the process using the last available task definition. You can pick a specific docker tag by using the --image-tag
argument. In this case, it changes the task definition and inserts the specified docker tag.
The task is run asynchronously by default. Using the --wait
argument, the task starts synchronously and returns the EXIT code of the container.
Executing a one-off process asynchronously:
runecs run rake db:migrate \
--service my-cluster/my-service \
--image-tag latest
Executing a one-off process synchronously:
runecs run rake db:migrate \
--service my-cluster/my-service \
--image-tag latest \
--wait
The main parameter is the name of the ECS service within which the command is to be executed. The parameter value consists of the cluster name and its service. To make it easier, we have introduced a command list that lists all these services in the specified region.
runecs list
Restarts all running tasks in the service.
runecs restart --service my-cluster/myservice
The services restart without downtime. The command initiates new tasks using the last definition. After reaching the running state, ECS automatically shuts down old tasks to achieve the desired number of running tasks.
Another option is to use the --kill
parameter, which shuts down running tasks in the service. If the service has health checks set up properly, ECS automatically starts new tasks to ensure that the desired number of tasks are running.
runecs restart --service my-cluster/myservice --kill
Deregisters old task definitions.
Use --keep-last
and --keep-days
to ensure that a certain number of definitions are always available.
runecs prune \
--service my-cluster/my-service \
--keep-last 10 --keep-days 5
Creates a new task definition with the specified image tag and updates the service to use the created task definition for new tasks.
runecs deploy \
--service my-cluster/my-service \
--image-tag latest
Prints a list of revisions of the task definition. Sorted from newest to oldest. Displays the Docker image URI used in the revision.
runecs revisions \
--service my-cluster/my-service \
--last 10
RunECS is distributed under Apache-2.0 license