The AWS CLI is powerful, but pairing it with Zsh takes it to another level. Autocompletion, aliases, environment isolation — all of it can make AWS access faster, safer, and less prone to human error. Yet the default setup is rarely tuned for speed or security. That’s where the right configuration comes in.
Why AWS Access in Zsh Matters
Engineers often juggle multiple AWS accounts. Switching credentials, remembering regions, and avoiding dangerous commands in production should not depend on human memory. Zsh lets you create a shell where aws commands are smart, contextual, and predictable. When AWS access is clean in Zsh, mistakes drop and delivery speeds up.
The Core Setup
Start with a dedicated AWS CLI profile for each account. Use ~/.aws/credentials and ~/.aws/config to store access keys and default regions. In Zsh, load the desired profile into your session with a simple function:
aws_profile() {
export AWS_PROFILE=$1
echo "Switched to AWS profile: $AWS_PROFILE"
}
Now switching accounts is one short command: aws_profile staging or aws_profile prod. This reduces accidental cross-account deployments.
Autocompletion That Works
Zsh supports AWS CLI autocompletion, but it’s often disabled by default. Enable it with:
autoload bashcompinit && bashcompinit
complete -C '/usr/local/bin/aws_completer' aws
Now typing aws ec2 desc<TAB> fills in describe-instances instantly. This saves time and eliminates typos that could lead to costly API calls.