浏览代码

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

Cristian Măgherușan-Stanciu 10 年之前
父节点
当前提交
4f4985fddc
共有 1 个文件被更改,包括 16 次插入1 次删除
  1. 16 1
      plugins/aws/aws.plugin.zsh

+ 16 - 1
plugins/aws/aws.plugin.zsh

@@ -14,10 +14,25 @@ function asp {
   fi
 }
 
+function aws_change_access_key {
+  if [[ "x$1" == "x" ]] then
+    echo "usage: $0 <profile.name>"
+    return 1
+  else
+    echo "Insert the credentials when asked."
+    asp $1
+    aws iam create-access-key
+    aws configure --profile $1
+    echo "You can now safely delete the old access key running 'aws iam delete-access-key --access-key-id ID'"
+    echo "Your current keys are:"
+    aws iam list-access-keys
+  fi
+}
+
 function aws_profiles {
   reply=($(grep '\[profile' "${AWS_CONFIG_FILE:-$HOME/.aws/config}"|sed -e 's/.*profile \([a-zA-Z0-9_\.-]*\).*/\1/'))
 }
-compctl -K aws_profiles asp
+compctl -K aws_profiles asp aws_change_access_key
 
 
 # AWS prompt