update to include aws aliases
This commit is contained in:
parent
e9ec4eaddc
commit
ee7f07b58a
4 changed files with 34 additions and 5 deletions
6
.aliases
6
.aliases
|
|
@ -133,3 +133,9 @@ alias reload="exec ${SHELL} -l"
|
|||
|
||||
# Print each PATH entry on a separate line
|
||||
alias path='echo -e ${PATH//:/\\n}'
|
||||
|
||||
# AWS aliases for profile management
|
||||
. ~/bin/awsAliases
|
||||
alias awsall="_awsListAll"
|
||||
alias awsp="_awsSwitchProfile"
|
||||
alias awswho="aws configure list"
|
||||
|
|
|
|||
|
|
@ -22,8 +22,3 @@ wttr()
|
|||
[ "$(tput cols)" -lt 125 ] && request+='?n'
|
||||
curl -H "Accept-Language: ${LANG%_*}" --compressed "$request"
|
||||
}
|
||||
|
||||
. ~/bin/awsAliases
|
||||
alias awsall="_awsListAll"
|
||||
alias awsp="_awsSwitchProfile"
|
||||
alias awswho="aws configure list"
|
||||
|
|
|
|||
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -12,3 +12,5 @@
|
|||
!.digrc
|
||||
!config
|
||||
!config/*
|
||||
!bin/*
|
||||
!bin
|
||||
|
|
|
|||
26
bin/awsAliases
Normal file
26
bin/awsAliases
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
|
||||
function _awsListAll() {
|
||||
|
||||
credentialFileLocation=${AWS_SHARED_CREDENTIALS_FILE};
|
||||
if [ -z $credentialFileLocation ]; then
|
||||
credentialFileLocation=~/.aws/credentials
|
||||
fi
|
||||
|
||||
while read line; do
|
||||
if [[ $line == "["* ]]; then echo "$line"; fi;
|
||||
done < $credentialFileLocation;
|
||||
};
|
||||
|
||||
function _awsSwitchProfile() {
|
||||
if [ -z $1 ]; then echo "Usage: awsp profilename"; return; fi
|
||||
|
||||
exists="$(aws configure get aws_access_key_id --profile $1)"
|
||||
if [[ -n $exists ]]; then
|
||||
export AWS_DEFAULT_PROFILE=$1;
|
||||
export AWS_PROFILE=$1;
|
||||
export AWS_REGION=$(aws configure get region --profile $1);
|
||||
echo "Switched to AWS Profile: $1";
|
||||
aws configure list
|
||||
fi
|
||||
};
|
||||
Loading…
Add table
Reference in a new issue