![](/img/trans.png)
[英]Process “aws ecs list-tasks” JSON output with “aws ecs execute-command”?
[英]Use grep to execute aws ecs 'execute' command
我想使用 aws ecs execute container 命令连接到我的容器
aws ecs execute-command --cluster <cluster> --task <task_id> --container <container_name> --interactive --command "/bin/bash"
目前我需要转到我的 aws 仪表板并获取任务 ID,但最近我意识到我可以使用
aws ecs list-tasks --cluster <cluster> --family <container> | grep -e "arn"
** 注意我仍然需要从结果中获取实际 id
我想运行第二个并使用输出调用第一个
我试过了:
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"
和
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"
有任何想法吗 ?
这是丑陋的,但它有效
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"\"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.