forked from mesosphere-backup/aws-cli
-
Notifications
You must be signed in to change notification settings - Fork 5
/
aws.sh
executable file
·40 lines (32 loc) · 827 Bytes
/
aws.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
# enable interruption signal handling
trap - INT TERM
if [[ ! -d "${HOME}/.aws" ]]; then
mkdir -p "${HOME}/.aws"
chown -R ${UID}:$(id -g ${UID}) "${HOME}/.aws"
fi
DOCKER_ARGS=""
# I/O Detection for TTY
# This allows use in subshells without CRLF line-endings from TTY.
if [ -t 0 ] && [ -t 1 ]; then
DOCKER_ARGS+=" -t"
fi
# TTY Detection for Interactivity
# This allows input in all but non-interactive shells.
if tty -s; then
DOCKER_ARGS+=" -i"
fi
# AWS Environment Variables
# Pass through all AWS variables, including session tokens and role assumption.
while read line; do
DOCKER_ARGS+=" -e ${line}"
done < <(env | grep "AWS_")
docker run --rm \
${DOCKER_ARGS} \
-v "$(pwd):/project" \
-v "${HOME}/.aws:/root/.aws" \
karlkfi/aws-cli \
"$@"