From 0a452db87974e3d58a0f1dcc443909ad5cb1e409 Mon Sep 17 00:00:00 2001 From: Rachael Booth Date: Mon, 11 Dec 2023 12:27:38 +0000 Subject: [PATCH] Add exec.sh script to execute command on app containers --- exec.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100755 exec.sh diff --git a/exec.sh b/exec.sh new file mode 100755 index 000000000..9d8dd6697 --- /dev/null +++ b/exec.sh @@ -0,0 +1,10 @@ +if [ $# -ne 2 ]; + then echo "Expected 2 arguments: exec.sh env command" +fi + +env=$1 +command=$2 +cluster="core-$env-app" + +taskId=$(aws ecs list-tasks --cluster $cluster --service-name "core-$env-app" --query "taskArns[0]" | grep -o "/$cluster/\w*" | sed "s@/$cluster/@@g") +aws ecs execute-command --cluster "core-$env-app" --task $taskId --interactive --command "$command"