my xfce4 dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.7 KiB

3 years ago
  1. # aws
  2. This plugin provides completion support for [awscli](https://docs.aws.amazon.com/cli/latest/reference/index.html)
  3. and a few utilities to manage AWS profiles and display them in the prompt.
  4. To use it, add `aws` to the plugins array in your zshrc file.
  5. ```zsh
  6. plugins=(... aws)
  7. ```
  8. ## Plugin commands
  9. * `asp [<profile>]`: sets `$AWS_PROFILE` and `$AWS_DEFAULT_PROFILE` (legacy) to `<profile>`.
  10. It also sets `$AWS_EB_PROFILE` to `<profile>` for the Elastic Beanstalk CLI.
  11. Run `asp` without arguments to clear the profile.
  12. * `asp [<profile>] login`: If AWS SSO has been configured in your aws profile, it will run the `aws sso login` command following profile selection.
  13. * `acp [<profile>] [<mfa_token>]`: in addition to `asp` functionality, it actually changes
  14. the profile by assuming the role specified in the `<profile>` configuration. It supports
  15. MFA and sets `$AWS_ACCESS_KEY_ID`, `$AWS_SECRET_ACCESS_KEY` and `$AWS_SESSION_TOKEN`, if
  16. obtained. It requires the roles to be configured as per the
  17. [official guide](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-role.html).
  18. Run `acp` without arguments to clear the profile.
  19. * `agp`: gets the current value of `$AWS_PROFILE`.
  20. * `aws_change_access_key`: changes the AWS access key of a profile.
  21. * `aws_profiles`: lists the available profiles in the `$AWS_CONFIG_FILE` (default: `~/.aws/config`).
  22. Used to provide completion for the `asp` function.
  23. ## Plugin options
  24. * Set `SHOW_AWS_PROMPT=false` in your zshrc file if you want to prevent the plugin from modifying your RPROMPT.
  25. Some themes might overwrite the value of RPROMPT instead of appending to it, so they'll need to be fixed to
  26. see the AWS profile prompt.
  27. ## Theme
  28. The plugin creates an `aws_prompt_info` function that you can use in your theme, which displays
  29. the current `$AWS_PROFILE`. It uses two variables to control how that is shown:
  30. * ZSH_THEME_AWS_PREFIX: sets the prefix of the AWS_PROFILE. Defaults to `<aws:`.
  31. * ZSH_THEME_AWS_SUFFIX: sets the suffix of the AWS_PROFILE. Defaults to `>`.
  32. ## Configuration
  33. [Configuration and credential file settings](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html) by AWS
  34. ### Scenario: IAM roles with a source profile and MFA authentication
  35. Source profile credentials in `~/.aws/credentials`:
  36. ```
  37. [source-profile-name]
  38. aws_access_key_id = ...
  39. aws_secret_access_key = ...
  40. ```
  41. Role configuration in `~/.aws/config`:
  42. ```
  43. [profile source-profile-name]
  44. mfa_serial = arn:aws:iam::111111111111:mfa/myuser
  45. region = us-east-1
  46. output = json
  47. [profile profile-with-role]
  48. role_arn = arn:aws:iam::9999999999999:role/myrole
  49. mfa_serial = arn:aws:iam::111111111111:mfa/myuser
  50. source_profile = source-profile-name
  51. region = us-east-1
  52. output = json
  53. ```