I am working with awscli and gcloud a lot. Sometimes I need to know whether I’m currently working on my lecturing account, or my work account. I’m thinking of a good indicator on which profile account and region I’m working right now. And oh-my-zsh already have that, since I installed it last year ?. This post only discuss on how to prepare the oh-my-zsh to have indicator with AWS Profile.
To begin with, check whether your AWS PROFILE has been setup properly. Check whether the ~/.aws/credentials
and ~/.aws/config
files are having the profiles that you need.
If the credentials and config do not have the profile yet, set it up as mentioned here from AWS. Notice that in credentials you just need to put your profile name in the square bracket, but in config, you have to put keyword profile
before the profile name.
Test the profile by executing one of the profiles. In this case, I’m using profile SGU.
$ aws ec2 describe-instances --profile sgu
The command line above will show all of instances under selected profile. If the profile has been set properly, then put it as the Environment Parameter into .zshrc
$ echo "export AWS_PROFILE=sgu" >> ~/.zshrc
Don’t forget to activate the plugin for aws in .zshrc
plugins=(
git
aws
zsh-syntax-highlighting
)
And this is what I have on my oh-my-zsh for awscli
That’s it. No more wondering on which profile is active. Above, I quickly noticed that currently I’m working on sgu profile with ap-southeast-1 region.