mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-26 01:57:26 +08:00
Compare commits
No commits in common. "673b9fc3317d48a169fe612575186b3eb1a42a13" and "bd5ebba834c53e730671d9d24d93eb98b812a579" have entirely different histories.
673b9fc331
...
bd5ebba834
@ -1,8 +1,7 @@
|
|||||||
# aws
|
# aws
|
||||||
|
|
||||||
This plugin provides completion support for [awscli v2](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/index.html)
|
This plugin provides completion support for [awscli](https://docs.aws.amazon.com/cli/latest/reference/index.html)
|
||||||
and a few utilities to manage AWS profiles/regions and display them in the prompt.
|
and a few utilities to manage AWS profiles/regions and display them in the prompt.
|
||||||
[awscli v1](https://docs.aws.amazon.com/cli/latest/userguide/cliv2-migration.html) is no longer supported.
|
|
||||||
|
|
||||||
To use it, add `aws` to the plugins array in your zshrc file.
|
To use it, add `aws` to the plugins array in your zshrc file.
|
||||||
|
|
||||||
@ -66,7 +65,7 @@ the current `$AWS_PROFILE` and `$AWS_REGION`. It uses four variables to control
|
|||||||
|
|
||||||
Source profile credentials in `~/.aws/credentials`:
|
Source profile credentials in `~/.aws/credentials`:
|
||||||
|
|
||||||
```ini
|
```
|
||||||
[source-profile-name]
|
[source-profile-name]
|
||||||
aws_access_key_id = ...
|
aws_access_key_id = ...
|
||||||
aws_secret_access_key = ...
|
aws_secret_access_key = ...
|
||||||
@ -74,7 +73,7 @@ aws_secret_access_key = ...
|
|||||||
|
|
||||||
Role configuration in `~/.aws/config`:
|
Role configuration in `~/.aws/config`:
|
||||||
|
|
||||||
```ini
|
```
|
||||||
[profile source-profile-name]
|
[profile source-profile-name]
|
||||||
mfa_serial = arn:aws:iam::111111111111:mfa/myuser
|
mfa_serial = arn:aws:iam::111111111111:mfa/myuser
|
||||||
region = us-east-1
|
region = us-east-1
|
||||||
|
|||||||
@ -160,39 +160,14 @@ function aws_change_access_key() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local profile="$1"
|
echo "Insert the credentials when asked."
|
||||||
# Get current access key
|
asp "$1" || return 1
|
||||||
local original_aws_access_key_id="$(aws configure get aws_access_key_id --profile $profile)"
|
AWS_PAGER="" aws iam create-access-key
|
||||||
|
AWS_PAGER="" aws configure --profile "$1"
|
||||||
|
|
||||||
asp "$profile" || return 1
|
echo "You can now safely delete the old access key running \`aws iam delete-access-key --access-key-id ID\`"
|
||||||
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
|
|
||||||
|
|
||||||
read -q "yn?Would you like to disable your previous access key (${original_aws_access_key_id}) now? "
|
|
||||||
case $yn in
|
|
||||||
[Yy]*)
|
|
||||||
echo -n "\nDisabling access key ${original_aws_access_key_id}..."
|
|
||||||
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}\`"
|
|
||||||
echo "Your current keys are:"
|
echo "Your current keys are:"
|
||||||
aws --no-cli-pager iam list-access-keys
|
AWS_PAGER="" aws iam list-access-keys
|
||||||
}
|
}
|
||||||
|
|
||||||
function aws_regions() {
|
function aws_regions() {
|
||||||
|
|||||||
@ -180,7 +180,6 @@ function has_typed_input() {
|
|||||||
|
|
||||||
# Check if there are updates available before proceeding
|
# Check if there are updates available before proceeding
|
||||||
if ! is_update_available; then
|
if ! is_update_available; then
|
||||||
update_last_updated_file
|
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user