Skip to content

Instantly share code, notes, and snippets.

@silvioramalho
Created January 17, 2021 16:26
Show Gist options
  • Save silvioramalho/36faffe77dca83d3cb67d24f1a4bf249 to your computer and use it in GitHub Desktop.
Save silvioramalho/36faffe77dca83d3cb67d24f1a4bf249 to your computer and use it in GitHub Desktop.
AWS ECS common commands

AWS ECS Common Commands

List Clusters

aws ecs list-clusters

List Services

aws ecs list-services

List Tasks

aws ecs list-tasks

Stop All tasks in services

aws ecs update-service --service sample-app-service --desired-count 0

Set 2 tasks in service

aws ecs update-service --service sample-app-service --desired-count 2

Stop tasks

aws ecs stop-task --task TASK_ID --cluster CLUSTER_NAME

List tasks definitions

aws ecs list-task-definitions

Run task definitions

aws ecs run-task --cluter CLUSTER_NAME --task-definition TASK_DEFINITION_NAME:VERSION

or add more tasks (Ex: 3)

aws ecs run-task --cluter CLUSTER_NAME --task-definition TASK_DEFINITION_NAME:VERSION --count 3

List service in some cluster with name CLUSTER_NAME

aws ecs list-services --cluster CLUSTER_NAME

Describe command (Fargate)

aws ecs describe-clusters

aws ecs describe-tasks

aws ecs describe-tasks --cluster default --tasks TASK_ID

Filter describe info (Customize output)

aws ecs describe-clusters --query '[clusters[*].[clusterName, runningTasksCount]]'

or

aws ecs describe-clusters | grep Name

or

aws ecs describe-tasks --cluster default --tasks TASK_ID --query 'tasks[*].{cpu:cpu, memoria:memory}'

Auto scaling with ECS (EC2)

aws autoscaling describe-auto-scaling-groups

aws autoscaling set-desired-capacity --auto-scaling-group-name AUTO_SCALING_GROUP_NAME_COMPLETE desired-capacity 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment