Prerequisites
- macOS 13 Ventura or later (Intel or Apple Silicon)
- Homebrew installed
Verify Homebrew is working:
brew --version
# Homebrew 4.x.xIf you do not have Homebrew yet:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"Install AWS CLI v2
brew install awscliThat is it. Homebrew handles the download, dependency resolution, and PATH setup automatically.
Verify the installation:
aws --version
# aws-cli/2.27.x Python/3.12.x Darwin/24.x source/arm64Configure Your First Profile
Interactive Setup
aws configureYou will be prompted for:
AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None]: us-east-1
Default output format [None]: jsonThis creates two files:
~/.aws/credentialsβ your access keys~/.aws/configβ region and output preferences
Named Profiles
For multiple AWS accounts:
aws configure --profile production
aws configure --profile stagingUse a profile:
aws s3 ls --profile production
# Or set as default for the session
export AWS_PROFILE=productionConfigure AWS SSO (Recommended)
If your organization uses AWS IAM Identity Center (SSO):
aws configure ssoFollow the prompts:
SSO session name (Recommended): my-company
SSO start URL [None]: https://my-company.awsapps.com/start
SSO region [None]: us-east-1
SSO registration scopes [sso:account:access]:Login:
aws sso login --profile my-sso-profileEnable Shell Autocompletion
Zsh (Default on macOS)
Add to ~/.zshrc:
autoload bashcompinit && bashcompinit
autoload -Uz compinit && compinit
complete -C '/opt/homebrew/bin/aws_completer' awsReload:
source ~/.zshrcBash
Add to ~/.bash_profile:
complete -C '/opt/homebrew/bin/aws_completer' awsNow you can tab-complete:
aws s3 <TAB>
aws ec2 describe-<TAB>Verify Everything Works
# Check identity
aws sts get-caller-identityExpected output:
{
"UserId": "AIDAIOSFODNN7EXAMPLE",
"Account": "123456789012",
"Arn": "arn:aws:iam::123456789012:user/lucaberton"
}Common Commands to Test
# List S3 buckets
aws s3 ls
# List EC2 instances
aws ec2 describe-instances \
--query 'Reservations[].Instances[].[InstanceId,State.Name,InstanceType]' \
--output table
# List Lambda functions
aws lambda list-functions --query 'Functions[].FunctionName' --output text
# Get current region
aws configure get regionUpdate AWS CLI
brew upgrade awscliCheck for available updates:
brew outdated awscliUninstall
brew uninstall awscliRemove configuration files:
rm -rf ~/.awsTroubleshooting
command not found: aws
Homebrew installs to /opt/homebrew/bin on Apple Silicon. Make sure it is in your PATH:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zshrc
source ~/.zshrcWrong Python Version Conflicts
The Homebrew formula bundles its own Python β it will not conflict with system Python or pyenv. If you see import errors:
brew reinstall awscliCredential Errors
# Check which credentials are being used
aws configure list
# Output shows source of each setting:
# Name Value Type Location
# ---- ----- ---- --------
# profile <not set> None None
# access_key ****************MPLE shared-credentials-file
# secret_key ****************EKEY shared-credentials-file
# region us-east-1 config-file ~/.aws/configMultiple AWS CLI Versions
If you previously installed via the .pkg installer:
# Remove the pkg version
sudo rm -rf /usr/local/aws-cli
sudo rm /usr/local/bin/aws
sudo rm /usr/local/bin/aws_completer
# Then use Homebrew version
brew install awscliAlternative: Official Installer
If you prefer not to use Homebrew:
# Download official installer
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
# Install
sudo installer -pkg AWSCLIV2.pkg -target /
# Verify
aws --versionThe Homebrew method is recommended because it handles updates (brew upgrade) and integrates with your existing package management workflow.
Environment Variables Reference
| Variable | Purpose |
|---|---|
AWS_PROFILE | Active named profile |
AWS_REGION | Override default region |
AWS_ACCESS_KEY_ID | Override access key |
AWS_SECRET_ACCESS_KEY | Override secret key |
AWS_SESSION_TOKEN | Temporary session token |
AWS_DEFAULT_OUTPUT | Output format (json/text/table) |