If you’re working with multiple AWS environments—like production, staging, or development—managing credentials can become chaotic. That’s where AWS CLI profiles come in.
In this guide, you’ll learn how to create an AWS CLI profile step by step, understand why it’s essential, and see how it helps you avoid mistakes like accidentally deploying to the wrong environment.
Why Use AWS CLI Profiles?

Using profiles allows you to:
- 🔐 Separate credentials for different AWS accounts or environments
- 🧪 Safely test in development without touching production
- 📁 Avoid overwriting credentials in
~/.aws/credentials - 🤖 Automate tasks using named profiles in CI/CD pipelines
✅ Best Practice: Never use your root account or production credentials without isolation!
Step-by-Step: Create AWS CLI Profile
Step 1: Install AWS CLI
If you haven’t already, install AWS CLI:
sudo apt install awscli -y
curl -L "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
#or
sudo ./aws/install --update
rm -rf aws/
rm awscliv2.zip
Step 2: Use aws configure --profile
Run this command to create a named profile
aws configure --profile myprofile
You will be prompted to enter:
AWS Access Key ID [None]: YOUR_ACCESS_KEY_ID
AWS Secret Access Key [None]: YOUR_SECRET_ACCESS_KEY
Default region name [None]: ap-southeast-1
Default output format [None]: json
Step 3: Check the Profile
Verify that your profile was created:
aws configure list --profile myprofile
You can also inspect the config files
~/.aws/credentials~/.aws/config
Step 4: Use Your AWS CLI Profile
Now you can run AWS CLI commands using your profile
aws s3 ls --profile myprofile
To set it as the default for your terminal session:
export AWS_PROFILE=myprofile
Optional: Manual Configuration in Files
You can edit the files directly if needed:
~/.aws/credentials
[myprofile]
aws_access_key_id = YOUR_ACCESS_KEY_ID
aws_secret_access_key = YOUR_SECRET_ACCESS_KEY
~/.aws/config
[profile myprofile]
region = us-east-1
output = json
Use Profiles in Scripts or Automation
When running scripts or Terraform, specify the profile:
AWS_PROFILE=myprofile terraform apply
In Python (with boto3):
session = boto3.Session(profile_name="myprofile")
Conclusion
Creating an AWS CLI profile is a best practice for anyone managing multiple AWS environments. It improves security, organization, and reliability, especially in automation and teamwork.
So now you know how to create an AWS CLI profile step by step, go ahead and structure your workflows the professional way.
If you want to get more information about the AWS profile, please view the blogs below: