Skip to content

Instantly share code, notes, and snippets.

@perpil
Created September 25, 2024 01:57
Show Gist options
  • Select an option

  • Save perpil/11623908ed057061a451b875383f2784 to your computer and use it in GitHub Desktop.

Select an option

Save perpil/11623908ed057061a451b875383f2784 to your computer and use it in GitHub Desktop.
AWS CLI alias for printing account alias and important part of ARN of current credentials
[toplevel]
whoami =
!f() {
echo `als=$(aws iam list-account-aliases --query 'AccountAliases[0]' --output text) && \
echo "\033[0;33m$als\033[0m:";`\
`callerid=$(aws sts get-caller-identity --query 'Arn' --output text) && \
(echo $callerid | cut -d: -f5-6)`
}; f
@perpil
Copy link
Author

perpil commented Sep 25, 2024

Usage: Write file to ~/.aws/cli/alias and run aws whoami

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