Skip to content

Instantly share code, notes, and snippets.

@stania
Last active May 29, 2020 07:43
Show Gist options
  • Save stania/c7b0a5898b37f282d0264e0417c76750 to your computer and use it in GitHub Desktop.
Save stania/c7b0a5898b37f282d0264e0417c76750 to your computer and use it in GitHub Desktop.
'aws' alias for AWS CLI v2 docker image considering running as non-root user
# usage : `. ./alias-aws.sh`
CONTAINER_HOME=/
if [[ "x$(id -u)" == "x0" ]]; then
CONTAINER_HOME=/root
fi
function awscli() {
docker run --rm -it -v ~/.aws:$CONTAINER_HOME/.aws -v $(pwd):/aws -u $(id -u):$(id -g) amazon/aws-cli $@
}
alias aws="awscli $@"
@stania
Copy link
Author

stania commented May 25, 2020

https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-docker.html

Aliasing guide in the manual is not suitable for non-root users because owner of created files from AWS CLI is root.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment