How to set default profile name in AWS CLI?

When I give the aws config list command, I get the following output for the default profile:

  Name Value Type Location ---- ----- ---- -------- profile <not set> None None 

However, when I give a command for a named profile, I get the profile name

 $ aws configure list --profile MyProfile Name Value Type Location ---- ----- ---- -------- profile MyProfile manual --profile 

I tried aws configure set profile Default to name the default profile as Default by reading the set 'command, I also tried aws configure set StoreAs Default because I thought the variable was named after I read this page . I want to do this because I want to have two profiles, and I want to switch between profiles using the AWS_DEFAULT_PROFILE environment AWS_DEFAULT_PROFILE .

+5
source share
3 answers

I also have several profiles, I use AWS_DEFAULT_PROFILE to switch back and forth. However, I called each profile somehow descriptive, for example, "aws-engineering" and "aws-production". Then I can use set AWS_DEFAULT_PROFILE=aws-engineering , and I'm good to go.

I do not have a DEFAULT profile specified in my ~ / .aws / config, this was intentional, so I always have to choose which environment I work with.

+9
source

You simply switch to the desired profile (for example: on Linux, use: export AWS_DEFAULT_PROFILE=MyProfile ), and then return to the default profile using export AWS_DEFAULT_PROFILE=default . "default" is the profile name assigned to your first profile when you created it.

+2
source

Setting the AWS_PROFILE environment AWS_PROFILE on the command line should specify the profile.

For instance:

Linux, macOS or Unix

 export AWS_PROFILE=user2 

Note. To undo, run: unset AWS_PROFILE .

To make the change permanent, add the above line to your user ~/.bashrc .

Window

 set AWS_PROFILE=user2 

Source: AWS CLI Customization User Guide Named profiles .

+2
source

All Articles