Skip to content

Instantly share code, notes, and snippets.

@voidrot
Last active October 23, 2021 22:23
Show Gist options
  • Save voidrot/ed1f22c0a9338f016ea29b10a5a1b923 to your computer and use it in GitHub Desktop.
Save voidrot/ed1f22c0a9338f016ea29b10a5a1b923 to your computer and use it in GitHub Desktop.
AWS Auto Profile Function
# This function makes use of ASDF (https://asdf-vm.com/) and its awscli plugin but can also be
# easily modified to use a standard awscli install
function aws() {
if [ ! -z "$AWS_PROFILE" ]; then
asdf exec aws --profile $AWS_PROFILE $@
elif [ -f ./.aws-profile ]; then
local profile
profile=$(cat ./.aws-profile | head -n 1)
asdf exec aws --profile $profile $@
else
asdf exec aws $@
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment