Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(toolbox): use AWS_PROFILE/AWS_REGION if set when calling awsi.sh #5041

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 "$*"