Skip to content

Commit 24d99ca

Browse files
authored
Merge pull request #13 from toricls/add-region-check
Add region check
2 parents 1beab95 + adaace1 commit 24d99ca

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

check-ecs-exec.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,12 @@ printf "${COLOR_DEFAULT}Prerequisites for the AWS CLI to use ECS Exec\n"
124124
printSectionHeaderLine
125125
##########################################################################################
126126

127-
REGION=$(${AWS_CLI_BIN} configure get region)
127+
REGION=$(${AWS_CLI_BIN} configure get region || echo "")
128128
AWS_REGION=${AWS_REGION:-$REGION}
129+
if [[ "x${AWS_REGION}" = "x" ]]; then
130+
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
131+
exit 1
132+
fi
129133

130134
callerIdentityJson=$(${AWS_CLI_BIN} sts get-caller-identity)
131135
ACCOUNT_ID=$(echo "${callerIdentityJson}" | jq -r ".Account")
@@ -180,6 +184,7 @@ printf "\n"
180184
printSectionHeaderLine
181185
printf "${COLOR_DEFAULT}Configurations for ECS task and other resources\n"
182186
printSectionHeaderLine
187+
printf "${COLOR_DEFAULT}Region : ${AWS_REGION}\n"
183188
printf "${COLOR_DEFAULT}Cluster: ${CLUSTER_NAME}\n"
184189
printf "${COLOR_DEFAULT}Task : ${TASK_ID}\n"
185190
printSectionHeaderLine

0 commit comments

Comments
 (0)