From 96df30a80f1356533eb3469f922ba682d92ef852 Mon Sep 17 00:00:00 2001 From: Claudius Heine Date: Tue, 5 May 2020 12:02:10 +0200 Subject: [PATCH] kas-docker: add `aws-dir` command parameter The `--aws-dir` parameter for the kas-docker script allows to specify a AWScli config directory which will then be mounted to `/etc/skel/.aws` and copied by kas into the internal home directory using the `AWS_*` environment variables. Signed-off-by: Claudius Heine Signed-off-by: Jan Kiszka --- kas-docker | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/kas-docker b/kas-docker index 2d05d28..e769c32 100755 --- a/kas-docker +++ b/kas-docker @@ -44,6 +44,7 @@ usage() printf "%b" "--ssh-dir\t\tDirectory containing SSH configurations.\n" printf "%b" "\t\t\tAvoid \$HOME/.ssh unless you fully trust the " \ "container.\n" + printf "%b" "--aws-dir\t\tDirectory containing AWScli configuration.\n" printf "%b" "--no-proxy-from-env\tDo not inherit proxy settings from " \ "environment.\n" exit 1 @@ -103,6 +104,11 @@ while [ $# -gt 0 ]; do SSH_DIR="$2" shift 2 ;; + --aws-dir) + [ $# -gt 2 ] || usage + AWS_DIR="$2" + shift 2 + ;; --no-proxy-from-env) NO_PROXY_FROM_ENV=1 shift 1 @@ -198,6 +204,16 @@ if [ -n "${SSH_DIR}" ] ; then set -- "$@" -v "$(readlink -f "${SSH_DIR}")":/etc/skel/.ssh:ro fi +if [ -n "${AWS_DIR}" ] ; then + if [ ! -d "${AWS_DIR}" ]; then + echo "Passed AWS_DIR '${AWS_DIR}' is not a directory" + exit 1 + fi + set -- "$@" -v "$(readlink -f "${AWS_DIR}")":/etc/skel/.aws:ro \ + -e AWS_CONFIG_FILE="${AWS_CONFIG_FILE:-/etc/skel/.aws/config}" \ + -e AWS_SHARED_CREDENTIALS_FILE="${AWS_SHARED_CREDENTIALS_FILE:-/etc/skel/.aws/credentials}" +fi + if [ -t 1 ]; then set -- "$@" -t -i fi