Configure Multiple Profiles
Create a named profile with
aws configure --profile <profile-name>.Enter the
AWS Access Key ID,AWS Secret Access Key,region name, andoutput formatto complete the setup.
The generated
configandcredentialsfiles will now contain separate entries keyed byprofile-name.
Use the Profiles
Basic Usage
Append
--profile <profile_name>to your CLI command to run it with the desired profile.For example, the command below uses the profile
Record Chinato list S3 buckets.
Simplify with Aliases
Typing
--profile <profile_name>every time gets tedious. On macOS or Linux, define a shell alias:bashalias aws_Record-China='aws --profile Record-China'From then on, simply run
aws_Record-Chinato execute AWS CLI commands with that profile.The screenshot below shows this alias in action.

Add the alias to
~/.zshrcso it persists:bashecho "alias aws_Record-China='aws --profile Record-China'" >> ~/.zshrc
Set a Default Profile
If you frequently use one account and don’t want to rely on aliases, set the
AWS_DEFAULT_PROFILEenvironment variable. Afterwards, runningawswill automatically use that profile.bashexport AWS_DEFAULT_PROFILE=Record-ChinaExample output:

Add the export to
~/.zshrcto keep it active across sessions:bashecho "export AWS_DEFAULT_PROFILE=Record-China" >> ~/.zshrc
