configure aws cli for multiple accounts1 min read

Prabhin Prabharkaran Administrator
DevOps Engineer

He is a Technical professional. He is a person who loves to share tricks and tips on the Internet. He Posts what he does!

follow me

AWS CLI helps to manage and administrate AWS resources from the command line rather than opening up the AWS management console.
AWS CLI is very useful when you lot of automation tasks etc. For example, if you need to stop /start an EC2 instance every day, you can use AWS CLI for that. and place it in a cron job.

Check this link to setup aws cli in Linux.

If you see the above link it shows you how to configure aws cli for your aws account. Let’s say what you will do if you want to manage multiple aws accounts using AWS cli. Some people say reconfigure your aws cli. Reconfiguring AWS cli every time is going to a hectic job when you work parallelly for two different customers.

In order to resolve this issue AWS came with a solution of creating profiles. Where each aws access and secret key get associated with each profile.


aws configure –profile <profile name>

aws configure --profile customer1

then enter your corresponding access and secret key


aws configure --profile customer2

then enter your corresponding access and secret key

Now I will show how to use this profile in real-time.

Let’s see if you want to list all the s3 buckets of customer1, use the below command

aws s3 ls --profile customer1


The only thing you need to add –profile key and its value to your every command. This lets aws cli to pick the corresponding AWS account.

aws s3 ls s3://images --profile customer2

happy learning 🙂


© 2020, Techrunnr. All rights reserved.

Questions Answered
Articles Written
Overall Points

Related posts

Leave a Reply