This repository has been archived on 2022-02-20. You can view files and clone it, but cannot push or open issues/pull-requests.
bash-shell-host/all/app/awscli

40 lines
949 B
Bash

#!/bin/bash
command -v docker >/dev/null 2>&1 || exit
aws_docker () {
local cred
local profile
local profile_env
if [[ $1 == "--cred" ]]; then
cred=$2
shift 2
else
cred=${HOME}/.aws
fi
if [[ $1 == "--profile" ]]; then
profile=$2
shift 2
else
profile=${AWS_PROFILE}
fi
[[ ! $(cat $cred/config 2> /dev/null | grep ${profile}]) ]] && echo no profile ${profile} in $cred/config && return
[[ $profile ]] && profile_env="--env AWS_PROFILE=${profile}"
# echo credentials directory $cred
# echo using profile $profile
[[ ! -f $cred/credentials ]] && echo no credentails file at $cred/credentails && return
# echo remaining args: $@
docker run --rm -it -v ${cred}:/root/.aws --env AWS_PAGER="" ${profile_env} -v $(pwd):/aws amazon/aws-cli "$@"
}
aws_docker-update () {
docker pull amazon/aws-cli:latest
}
_alt_=$([[ $(command -v aws >/dev/null 2>&1) ]] || echo d)
alias aws${_alt_}='aws_docker'
alias aws${_alt_}-update='aws_docker_update'
unset _alt_