Created
February 7, 2017 03:25
-
-
Save mlf4aiur/83833e9905bfb5779fc0a3035bca85c5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function stop_ecs_service_tasks () { | |
| local cluster_name=$1 | |
| local service_name=$2 | |
| local wait_time=${3:-10} | |
| local tasks | |
| local task | |
| # Get tasks | |
| tasks=$(aws --output json \ | |
| ecs list-tasks \ | |
| --cluster "${cluster_name}" \ | |
| --service-name "${service_name}" | \ | |
| jq '.taskArns[]' | sed 's@.*task/@@' | tr -d '"' | tr "\n" " ") | |
| # Stop tasks | |
| for task in ${tasks}; do | |
| echo "Stoping task: ${cluster_name} ${service_name} ${task}" | |
| aws ecs stop-task --task "${task}" --cluster "${cluster_name}" | |
| sleep "${wait_time}" | |
| done | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment