Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion check-ecs-exec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,19 @@ callerIdentityJson=$(${AWS_CLI_BIN} sts get-caller-identity)
ACCOUNT_ID=$(echo "${callerIdentityJson}" | jq -r ".Account")
MY_IAM_ARN=$(echo "${callerIdentityJson}" | jq -r ".Arn")

# Check whether the AWS CLI v1.19.28/v2.1.30 or later exists
# Check task existence
describedTaskJson=$(${AWS_CLI_BIN} ecs describe-tasks \
--cluster "${CLUSTER_NAME}" \
--tasks "${TASK_ID}" \
--output json)
existTask=$(echo "${describedTaskJson}" | jq -r ".tasks[0].taskDefinitionArn")
if [[ "x${existTask}" = "xnull" ]]; then
printf "${COLOR_RED}Pre-flight check failed: The specified ECS task does not exist.\n\
Make sure the parameters you have specified for cluster \"${CLUSTER_NAME}\" and task \"${TASK_ID}\" are both valid.\n"
exit 1
fi

# Check whether the AWS CLI v1.19.28/v2.1.30 or later exists
executeCommandEnabled=$(echo "${describedTaskJson}" | jq -r ".tasks[0].enableExecuteCommand")
if [[ "x${executeCommandEnabled}" = "xnull" ]]; then
printf "${COLOR_RED}Pre-flight check failed: ECS Exec requires the AWS CLI v1.19.28/v2.1.30 or later.\n\
Expand Down