I would like to connect to my containers with aws ecs execute container command
aws ecs execute-command --cluster <cluster> --task <task_id> --container <container_name> --interactive --command "/bin/bash"
Currently I need to go to my aws dashboard and grab the task id but recently I realized I could just use
aws ecs list-tasks --cluster <cluster> --family <container> | grep -e "arn"
** Note I still need to grab the actual id from the result
I would like to run the second one and use the output to call the first one
I have tried:
aws ecs list-tasks --cluster <cluster>--family <family> | grep -e "arn" | aws ecs execute-command --cluster <cluster> --task $1 --container <container> --interactive --command "/bin/bash"
and
aws ecs execute-command --cluster <cluster>--task $(aws ecs list-tasks --cluster <cluster> --family <task-family> | grep -e \"arn\" | awk '{print $1}') --container <container-name> --interactive --command "/bin/bash"
any ideas ?
这是丑陋的,但它有效
alias connect-to-app="aws ecs execute-command --cluster <cluster> --task \"$(aws ecs list-tasks --cluster <cluster> --family <family> | grep -e "arn" | grep -o '/<cluster>/\w*' | sed "s@/<cluster>/@@g")\" --container <container> --interactive --command \"/bin/bash"\"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.