Created
December 24, 2021 08:04
-
-
Save tkhk/10fc24f148ef04ce0547ac477b23615c to your computer and use it in GitHub Desktop.
Support ECS exec '/bin/sh'
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 | |
set -eu | |
function cluster_arn() { | |
select cluster in $(aws ecs list-clusters --query "clusterArns[*]" --output text) | |
do | |
echo ${cluster} | |
break | |
done | |
} | |
function task_arn() { | |
select service in $(aws ecs list-tasks --cluster ${1} --query "taskArns[*]" --output text) | |
do | |
echo ${service} | |
break | |
done | |
} | |
echo "Select Cluster: " | |
cluster=$(cluster_arn) | |
echo "" | |
echo "Select Task: " | |
task=$(task_arn ${cluster}) | |
echo "" | |
read -p "Input Container: " container | |
aws ecs execute-command --cluster ${cluster} \ | |
--task ${task} \ | |
--container ${container} \ | |
--interactive \ | |
--command "/bin/sh" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment