4f4985fddc632a1d9745aec94ce95bea10006f97

Author
Cristian Măgherușan-Stanciu <cristian.magherusan-stanciu@here.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

aws: added an alias for changing the AWS access key set on a profile

Diff

 1diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh
 2index 944557e14ae02db0bf43cb4c39a68f12b9f90233..7005af2d65932f258ab2f026d1eb6b2530a4f40b 100644
 3--- a/plugins/aws/aws.plugin.zsh
 4+++ b/plugins/aws/aws.plugin.zsh
 5@@ -14,10 +14,25 @@ function asp {
 6   fi
 7 }
 8 
 9+function aws_change_access_key {
10+  if [[ "x$1" == "x" ]] then
11+    echo "usage: $0 <profile.name>"
12+    return 1
13+  else
14+    echo "Insert the credentials when asked."
15+    asp $1
16+    aws iam create-access-key
17+    aws configure --profile $1
18+    echo "You can now safely delete the old access key running 'aws iam delete-access-key --access-key-id ID'"
19+    echo "Your current keys are:"
20+    aws iam list-access-keys
21+  fi
22+}
23+
24 function aws_profiles {
25   reply=($(grep '\[profile' "${AWS_CONFIG_FILE:-$HOME/.aws/config}"|sed -e 's/.*profile \([a-zA-Z0-9_\.-]*\).*/\1/'))
26 }
27-compctl -K aws_profiles asp
28+compctl -K aws_profiles asp aws_change_access_key
29 
30 
31 # AWS prompt