You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `check-ecs-exec.sh` automatically detects your MFA configuration for the AWS CLI. But you can also explicitly specify which MFA device to use by setting the ARN of the MFA device to `AWS_MFA_SERIAL` environment variable.
42
+
43
+
_Example 4 - Switch AWS CLI binaries_
40
44
41
45
If you have multiple AWS CLI installations in your environment, both AWS CLI v1 and v2 for example, you can choose which AWS CLI binary to use by passing the `AWS_CLI_BIN` env variable.
REGION=$(${AWS_CLI_BIN} configure get region ||echo"")
124
+
export AWS_REGION=${AWS_REGION:-$REGION}
125
+
# Check region configuration in "source_profile" if the user uses MFA configurations
126
+
source_profile=$(${AWS_CLI_BIN} configure get source_profile ||echo"")
127
+
if [ "${AWS_REGION}"="" ] && [ "${source_profile}"!="" ];then
128
+
export AWS_REGION=$(${AWS_CLI_BIN} configure get region --profile ${source_profile}||echo"")
129
+
fi
130
+
if [[ "x${AWS_REGION}"="x" ]];then
131
+
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
132
+
exit 1
133
+
fi
134
+
122
135
## 2. CHECK PREREQUISITES FOR USING ECS EXEC FEATURE VIA AWS CLI #########################
123
136
printf"\n"
124
137
printSectionHeaderLine
125
138
printf"${COLOR_DEFAULT}Prerequisites for the AWS CLI to use ECS Exec\n"
REGION=$(${AWS_CLI_BIN} configure get region ||echo"")
130
-
AWS_REGION=${AWS_REGION:-$REGION}
131
-
if [[ "x${AWS_REGION}"="x" ]];then
132
-
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
133
-
exit 1
142
+
# MFA
143
+
AWS_MFA_SERIAL=${AWS_MFA_SERIAL:-$(${AWS_CLI_BIN} configure get mfa_serial || echo "")}
144
+
ROLE_TO_BE_ASSUMED=$(${AWS_CLI_BIN} configure get role_arn ||echo"")
145
+
SOURCE_PROFILE=$(${AWS_CLI_BIN} configure get source_profile ||echo"")
146
+
# Normally we don't need to ask MFA code thanks to the AWS CLI
147
+
# but we do need to prompt explicitly if the "AWS_MFA_SERIAL" value only exists without "role_arn" and "source_profile"
0 commit comments