Installing AWS CLI
To install the AWS Command Line Interface (CLI):
- Windows: Download and run the .msi installer from the AWS website. Verify by typing
aws --version
in the command prompt. - macOS: Use Homebrew and run
brew install awscli
in Terminal. Verify withaws --version
. - Linux: In Terminal, use
sudo apt-get install awscli
(most distributions) orsudo dnf install awscli
(Fedora). Verify withaws --version
.
Confirming your installed version ensures proper AWS service interaction.
Configuring AWS CLI Access Keys
To obtain AWS access keys:
- Log into AWS Management Console
- Click your username and select "Security Credentials"
- In "Access keys", click "Create Access Key"
- Download and securely store the CSV file with your keys
Configure keys using AWS CLI:
- Open command prompt or Terminal
- Type
aws configure
- Enter your access key ID, secret access key, preferred region, and output format
This saves your input in ~/.aws/credentials
and config
. Keep these files secure.
Creating Multiple AWS CLI Profiles
Create a new profile using:
aws configure --profile profile_name
For manual configuration, edit ~/.aws/config
and ~/.aws/credentials
directly.
List existing profiles:
aws configure list-profiles
Use a specific profile by adding --profile profile_name
to any AWS CLI command.
For a session-wide switch:
export AWS_PROFILE=profile_name
Switching AWS Profiles
Two main methods for switching profiles:
- Using
--profile
flag:aws s3 ls --profile profile_name
- Setting environment variable:
export AWS_PROFILE=profile_name
Check active profile:
aws configure list

Verifying AWS CLI Configurations
Verify configurations using:
aws configure list
: Displays current configuration summary Add--profile profile_name
for specific profilesaws sts get-caller-identity
: Confirms access key connection to correct AWS account
Regular verification helps maintain accurate profile configurations.
Effective AWS CLI profile management streamlines workflows when handling multiple accounts. By utilizing named profiles and environment variables, users can seamlessly switch between different AWS accounts or regions from a single command-line interface.
This comprehensive guide enables users to configure and manage multiple AWS CLI profiles, enhancing productivity and security in multi-account environments.
- Amazon Web Services. AWS Command Line Interface User Guide.
- Amazon Web Services. Working with AWS Credentials.
- Amazon Web Services. Named Profiles.