Skip to content

Commit

Permalink
Merge pull request #5041 from systeminit/fnichol/awsi-profile-region-…
Browse files Browse the repository at this point in the history
…env-vars

feat(toolbox): use AWS_PROFILE/AWS_REGION if set when calling `awsi.sh`
  • Loading branch information
fnichol authored Nov 29, 2024
2 parents a1b41f9 + a63bd55 commit 654d7c0
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions component/toolbox/awsi.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
#!/usr/bin/env bash
set -eu

if [[ -n "${DEBUG:-}" ]]; then set -v; fi
if [[ -n "${TRACE:-}" ]]; then set -xv; fi

# If running in Github, we don't have an interactive
# terminal so the commands can't request user input
if [ "$GITHUB_ACTIONS" = "true" ]; then
if [[ "${GITHUB_ACTIONS:-}" = "true" ]]; then
terminal="-t"
else
terminal="-it"
fi

docker run --rm "${terminal}" \
-v ~/.aws:/root/.aws \
-v "$(pwd)":/aws \
-e AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}" \
-e AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}" \
-e AWS_SESSION_TOKEN="${AWS_SESSION_TOKEN}" \
systeminit/toolbox:stable "$*"
args=(
--rm
"${terminal}"
-v ~/.aws:/root/.aws
-v "$(pwd)":/aws
-e AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID:-}"
-e AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY:-}"
-e AWS_SESSION_TOKEN="${AWS_SESSION_TOKEN:-}"
)

if [[ -n "${AWS_PROFILE:-}" ]]; then
args+=(-e AWS_PROFILE="${AWS_PROFILE}")
fi

if [[ -n "${AWS_REGION:-}" ]]; then
args+=(-e AWS_REGION="${AWS_REGION}")
fi

docker run "${args[@]}" systeminit/toolbox:stable "$*"

0 comments on commit 654d7c0

Please sign in to comment.