@@ -160,14 +160,39 @@ function aws_change_access_key() {
...
@@ -160,14 +160,39 @@ function aws_change_access_key() {
return 1
return 1
fi
fi
echo"Insert the credentials when asked."
local profile="$1"
asp "$1"||return 1
# Get current access key
AWS_PAGER="" aws iam create-access-key
local original_aws_access_key_id="$(aws configure get aws_access_key_id --profile$profile)"
AWS_PAGER="" aws configure --profile"$1"
asp "$profile"||return 1
echo"Generating a new access key pair for you now."
if aws --no-cli-pager iam create-access-key;then
echo"Insert the newly generated credentials when asked."
aws --no-cli-pager configure --profile$profile
else
echo"Current access keys:"
aws --no-cli-pager iam list-access-keys
echo"Profile \"${profile}\" is currently using the $original_aws_access_key_id key. You can delete an old access key by running \`aws --profile $profile iam delete-access-key --access-key-id AccessKeyId\`"
return 1
fi
echo"You can now safely delete the old access key running \`aws iam delete-access-key --access-key-id ID\`"
read-q"yn?Would you like to disable your previous access key (${original_aws_access_key_id}) now? "
if aws --no-cli-pager update-access-key --access-key-id${original_aws_access_key_id}--status Inactive;then
echo"done."
else
echo"\nFailed to disable ${original_aws_access_key_id} key."
fi
;;
*)
echo""
;;
esac
echo"You can now safely delete the old access key by running \`aws --profile $profile iam delete-access-key --access-key-id ${original_aws_access_key_id}\`"