Skip to content

Commit

Permalink
Merge pull request #13 from toricls/add-region-check
Browse files Browse the repository at this point in the history
Add region check
  • Loading branch information
toricls authored Mar 30, 2021
2 parents 1beab95 + adaace1 commit 24d99ca
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion check-ecs-exec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,12 @@ printf "${COLOR_DEFAULT}Prerequisites for the AWS CLI to use ECS Exec\n"
printSectionHeaderLine
##########################################################################################

REGION=$(${AWS_CLI_BIN} configure get region)
REGION=$(${AWS_CLI_BIN} configure get region || echo "")
AWS_REGION=${AWS_REGION:-$REGION}
if [[ "x${AWS_REGION}" = "x" ]]; then
printf "${COLOR_RED}Pre-flight check failed: Missing AWS region. Use the \`aws configure set default.region\` command or set the \"AWS_REGION\" environment variable.\n" >&2
exit 1
fi

callerIdentityJson=$(${AWS_CLI_BIN} sts get-caller-identity)
ACCOUNT_ID=$(echo "${callerIdentityJson}" | jq -r ".Account")
Expand Down Expand Up @@ -180,6 +184,7 @@ printf "\n"
printSectionHeaderLine
printf "${COLOR_DEFAULT}Configurations for ECS task and other resources\n"
printSectionHeaderLine
printf "${COLOR_DEFAULT}Region : ${AWS_REGION}\n"
printf "${COLOR_DEFAULT}Cluster: ${CLUSTER_NAME}\n"
printf "${COLOR_DEFAULT}Task : ${TASK_ID}\n"
printSectionHeaderLine
Expand Down

0 comments on commit 24d99ca

Please sign in to comment.