-
-
Save n3bulous/7efff0f2bbac59e097e0328bf03f78a2 to your computer and use it in GitHub Desktop.
ECS SSH
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
| #!/bin/bash | |
| CLUSTER=$1 | |
| SERVICE=$2 | |
| CONTAINER=$3 | |
| shift 3 | |
| AWS_ARGS=$@ | |
| LIST=`aws ecs list-tasks --cluster $CLUSTER --service $SERVICE $AWS_ARGS` | |
| if [ "$?" -ne "0" ]; then | |
| exit 1 | |
| fi | |
| ARNS=($(ruby -rjson -e "puts JSON.parse('${LIST}')['taskArns']")) | |
| i=0 | |
| for ARN in ${ARNS[@]}; do | |
| i=$((i+1)) | |
| echo "$i) ${ARN}" | |
| done | |
| echo -n "Enter a number from 1 (default) to $i to select a task: " | |
| read -r ARN_NUM | |
| ARN_NUM=${ARN_NUM:-1} | |
| TASK=${ARNS[ARN_NUM - 1]} | |
| aws ecs execute-command --cluster $CLUSTER --task $TASK --container $CONTAINER --interactive --command bash $AWS_ARGS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment