Skip to content

Instantly share code, notes, and snippets.

@wilmoore
Last active December 4, 2024 02:02
Show Gist options
  • Select an option

  • Save wilmoore/c37d871ccd294629aab3068b1f6d8aea to your computer and use it in GitHub Desktop.

Select an option

Save wilmoore/c37d871ccd294629aab3068b1f6d8aea to your computer and use it in GitHub Desktop.
Software Engineering :: Cloud :: AWS :: CLI :: Command :: Alias

Software Engineering :: Cloud :: AWS :: CLI :: Command :: Alias

⪼ Made with 💜 by Polyglot.

Similar to git aliases

Initialize Alias File
mkdir -p ~/.aws/cli && echo '[toplevel]' > ~/.aws/cli/alias
Example Alias File
[toplevel]

fed = ! cat ~/.aws/credentials | grep '^\(account\|assumed\)_' | cut -d ' ' -f3 | tr '\n' ' ' | awk '{ printf "Account: %s (%s) Role: %s", $1, $2, $3 }'
account = fed

identity = sts get-caller-identity

NOTE: The above alias file defines an identity command, as well as a fed command and an account command that is itself an alias to another alias fed.

Alias Usage
> aws account
Account: 755203376857 (AWS_MQ@teamaol.com) Role: sso/fed.admin.user
More Examples & Resources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment