Check for AWS credentials file in AWS plugin

pull/502/head
Eduardo Bellido Bellido 2015-06-11 00:26:25 +02:00
parent 1e32b49bd7
commit d4c1ded1cc
1 changed files with 8 additions and 2 deletions

View File

@ -4,6 +4,12 @@ about-plugin 'AWS helper functions'
function awskeys { function awskeys {
about 'helper function for AWS credentials file' about 'helper function for AWS credentials file'
group 'aws' group 'aws'
if [[ ! -f ~/.aws/credentials ]]; then
echo "AWS credentials file not found"
return 1
fi
if [[ $# -eq 1 ]] && [[ "$1" = "list" ]]; then if [[ $# -eq 1 ]] && [[ "$1" = "list" ]]; then
__awskeys_list "$2" __awskeys_list "$2"
elif [[ $# -eq 1 ]] && [[ "$1" = "unset" ]]; then elif [[ $# -eq 1 ]] && [[ "$1" = "unset" ]]; then
@ -39,8 +45,8 @@ function __awskeys_list {
local credentials_list="$(egrep '^\[ *[a-zA-Z0-9_-]+ *\]$' ~/.aws/credentials)" local credentials_list="$(egrep '^\[ *[a-zA-Z0-9_-]+ *\]$' ~/.aws/credentials)"
if [[ -n $"{credentials_list}" ]]; then if [[ -n $"{credentials_list}" ]]; then
echo -e "Available credentials profiles:\n" echo -e "Available credentials profiles:\n"
for cred in ${credentials_list}; do for profile in ${credentials_list}; do
echo " $(echo ${cred} | tr -d "[]")" echo " $(echo ${profile} | tr -d "[]")"
done done
echo echo
else else