Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[completion file] AWS profiles



Various tools working with AWS honor a common set of environment
variables for defining access.  One of those is `AWS_PROFILE`, which
points to a name which is used for looking up various other values.
Profiles can be defined in ~/.aws/config in sections `[profile FOO]` or
in ~/.aws/credentials in sections `[FOO]` (notice dropped keyword).

For me, I always want the credentials file entries, because with a
reasonable `[default]` section you don't need per-profile entries in the
config file.

This is what I'm using and it might be suitable for inclusion with zsh?
Any improvements?

-------------------------8< _aws_credentials >8-------------------------
#compdef -value-,AWS_PROFILE,-default-

local expl

_wanted awscredentials expl 'AWS credentials profile name' \
  compadd "$@" - ${${${(Mo)${(f)"$(<${AWS_SHARED_CREDENTIALS_FILE:-$HOME/.aws/credentials})"}##\[*\]}#\[}%\]}
-------------------------8< _aws_credentials >8-------------------------

Use in conjunction with:

  zstyle ':completion:*' fake-parameters \
    AWS_PROFILE AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY \
    AWS_DEFAULT_REGION AWS_SHARED_CREDENTIALS_FILE

for a better AWS-using experience.



Messages sorted by: Reverse Date, Date, Thread, Author