Table of Contents
1. What Are AWS CLI Profiles?
AWS CLI profiles allow you to configure and manage multiple sets of AWS credentials and settings. Each profile corresponds to a specific AWS account or role, enabling you to seamlessly switch between them while using the AWS CLI.
2. Configuring Multiple Profiles
To set up profiles, follow these steps:
Using aws configure
command
- Run the Configuration command:
aws configure --profile profile_name
Replace it profile_name
with a name like dev
"or."prodaccount2
- Enter the Required Information:
- AWS Access Key ID
- AWS Secret Access Key
- Default Region Name (e.g.,
us-west-2
) - Default Output Format (e.g.,
json
)
- Repeat for each AWS account, using different profile names.
Manually Editing Configuration Files
For finer control, you can manually edit the configuration files.
- Credentials File
vim ~/.aws/credentials %USERPROFILE%\.aws\credentials
Using AWS CLI with Multiple Profiles
To run AWS CLI commands using a specific profile, use the --profile
option:
aws s3 ls --profile profile1
Setting Environment Variables (Optional)
For convenience, you can set the AWS_PROFILE
environment variable to use a specific profile for the duration of your terminal session:
export AWS_PROFILE=profile1
Verifying Your Configuration
To ensure your profiles are set up correctly, you can check your account identity:
aws sts get-caller-identity --profile profile1