Skip to content

Commit 71a408a

Browse files
authored
fix: Check against multiple aws profiles in build instance credentails (#13421)
We were loading multiple credentials as a newline-delimited string if there was more than a single profile. Also, quotes the credentials when passing them to docker run in `bootstrap_ec2`.
1 parent 7768ff8 commit 71a408a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

ci3/bootstrap_ec2

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ if [ -z "${AWS_ACCESS_KEY_ID:-}" ] || [ -z "${AWS_SECRET_ACCESS_KEY:-}" ]; then
9191
echo "AWS credentials are being set from ~/.aws/build_instance_credentials."
9292
export AWS_ACCESS_KEY_ID=$(grep aws_access_key_id ~/.aws/build_instance_credentials | awk '{print $3}')
9393
export AWS_SECRET_ACCESS_KEY=$(grep aws_secret_access_key ~/.aws/build_instance_credentials | awk '{print $3}')
94+
if [[ $(echo "$AWS_ACCESS_KEY_ID" | wc -l) > 1 ]] || [[ $(echo "$AWS_SECRET_ACCESS_KEY" | wc -l) > 1 ]] ; then
95+
echo "Error: multiple AWS credentials found in ~/.aws/build_instance_credentials. Make sure you have only one profile defined."
96+
exit 1
97+
fi
9498
fi
9599

96100
# If we're asking to not terminate the instance automatically, we also don't want to remove the container.
@@ -297,8 +301,8 @@ function run {
297301
-e L1_DEPLOYMENT_PRIVATE_KEY=${L1_DEPLOYMENT_PRIVATE_KEY:-} \
298302
-e DRY_RUN=${DRY_RUN:-0} \
299303
-e DOCKERHUB_PASSWORD=${DOCKERHUB_PASSWORD:-} \
300-
-e AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID:-} \
301-
-e AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY:-} \
304+
-e AWS_ACCESS_KEY_ID=\"${AWS_ACCESS_KEY_ID:-}\" \
305+
-e AWS_SECRET_ACCESS_KEY=\"${AWS_SECRET_ACCESS_KEY:-}\" \
302306
-e BUILD_SYSTEM_DEBUG=${BUILD_SYSTEM_DEBUG:-} \
303307
-e GITHUB_TOKEN=${GITHUB_TOKEN:-} \
304308
-e NETLIFY_SITE_ID=${NETLIFY_SITE_ID:-} \

0 commit comments

Comments
 (0)