AWS CLI

How to switch profiles for AWS CLI

Let's say that you have multiple profiles in ~/.aws/credentials. (default for work and personal for personal use.)

[default]
aws_access_key_id = XXXXXXXX
aws_secret_access_key = YYYYYYYY

[personal]
aws_access_key_id = VVVVVVVV
aws_secret_access_key = WWWWWWWW

We want to use AWS CLI with our personal profile. How do we do that?

Well, the solution is to simply export AWS_PROFILE in your terminal.

$ export AWS_PROFILE=personal

Going back to default is also easy.

$ export AWS_PROFILE=default

Credits

Last updated