Aws-cli: aws configure --profile "profilename" prompts "The config profile (profilename) could not be found"

Created on 7 Nov 2019  路  12Comments  路  Source: aws/aws-cli

aws --version

aws-cli/1.16.276 Python/2.7.14 Darwin/18.0.0 botocore/1.13.12

According to https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html#cli-quick-configuration-multi-profiles , this configure command should work. However, error message reads: "The config profile (profilename) could not be found"

Temporary fix:

vim ~/.aws/config

and add "[profilename]" and then rerun the configure command

bug

Most helpful comment

I also seem to get this - but only if the AWS_PROFILE environment variable is also set (to a profile that does not yet exist). If I then unset this var then the aws configure set.... command works fine.

I noticed it when I ran the command aws configure set ... --profile AAA but got the error "_The config profile (BBB) could not be found_", which was strange.
On closer inspection, the AWS_PROFILE var was set to "BBB" but that profile did not yet exist!

Hope that helps...

All 12 comments

@BruceWangNo1, I'm sorry but I can't repro your problem. The aws configure --profile _newprofilename_ command works the way I documented it on that page. I just ran the following, and "junk" did NOT exist in there before I did ran these commands.

```
[~] $ aws --version
aws-cli/1.16.273 Python/2.7.16 Darwin/18.7.0 botocore/1.13.9

[~] $ aws configure --profile junk
AWS Access Key ID [None]: 12345
AWS Secret Access Key [None]: 12345
Default region name [None]: us-west-2
Default output format [None]: json

[~] $ cat ~/.aws/credentials
[junk]
aws_access_key_id = 12345
aws_secret_access_key = 12345

[~] $ cat ~/.aws/config
[profile junk]
output = json
region = us-west-2
'''

@bisdavid Thank you for your help. Probably not worth the effort to dive into this. I got a temporary fix anyway.

For the record, I'm getting the same thing too - instead of preparing to write the profile, it looks like aws configure --profile <newprofilename> is trying to read it first or something. Or maybe even just a Python 2 vs Python 3 thing?

As documented here.

And yes, we can work around it by manually editing the config files, but there's a reason we have this CLI command.

Stephens-MacBook-Pro:.aws steve$ aws --version
aws-cli/1.18.28 Python/2.7.15 Darwin/19.3.0 botocore/1.15.28
Stephens-MacBook-Pro:.aws steve$ more config
[default]
region = us-east-2
output = json
[plugins]
endpoint = awscli_plugin_endpoint
Stephens-MacBook-Pro:.aws steve$ more credentials 
[default]
aws_access_key_id = <mykey>
aws_secret_access_key = <snip>
Stephens-MacBook-Pro:.aws steve$ aws configure --profile wasabi

The config profile (wasabi) could not be found
Stephens-MacBook-Pro:.aws steve$ 

I am also able to repro this

lavignes@hostname ~ %aws --version
aws-cli/1.18.38 Python/3.6.9 Linux/5.3.0-46-generic botocore/1.15.38
lavignes@hostname ~ %aws configure --profile test

The config profile (test) could not be found

I can reproduce this as well:

dfezzie@hostname ~> aws --version
aws-cli/1.18.14 Python/3.7.6 Darwin/18.7.0 botocore/1.15.14
dfezzie@hostname ~> aws configure --profile test

The config profile (test) could not be found

@lavignes @steve-estes and @dfezzie ,
Can you try upgrading to V2, it looks to me like this problem doesn't happen anymore on the newest version of the SDK.

I also seem to get this - but only if the AWS_PROFILE environment variable is also set (to a profile that does not yet exist). If I then unset this var then the aws configure set.... command works fine.

I noticed it when I ran the command aws configure set ... --profile AAA but got the error "_The config profile (BBB) could not be found_", which was strange.
On closer inspection, the AWS_PROFILE var was set to "BBB" but that profile did not yet exist!

Hope that helps...

Ah I see, thanks @ch-gareth !

so if you have a $AWS_PROFILE set it won't let you configure a new profile through aws configure --profile, hmm I'll mark this as a bug then, that should not be the behavior.

Hmmm, sort of. If _$AWS_PROFILE_ is set to a profile that exists / is defined then it seems OK for me. It just throws an error if that var is set to a profile which isn't configured (yet). Which makes sense really from that error message.
In my case, I was wanting to configure a new profile, but _$AWS_PROFILE_ was already set to the name of that new profile. That's what threw me for a while and was causing me the error above (and what brought me to this page!).
Could be these others here were having the same issue. I suspect the original message workaround _"vim ~/.aws/config ...add "[profilename]" and then rerun the configure command"_ probably would also have worked for me too.
Perhaps the aws configure set ...... --profile profile-name command could create a section for profile-name if it doesn't yet exist?

@ch-gareth for me I don't have the AWS_PROFILE environment variable set and this still repros.

Perhaps the aws configure set ...... --profile profile-name command could create a section for profile-name if it doesn't yet exist?

I'm 99% sure that is the bug here. It is supposed to do that.

Hi @lavignes & @KaibaLopez. Yes, I see.
Interesting that it will create a new config section for me (I've just discovered) - but not if I have AWS_PROFILE set to a name that isn't already in the config. Seems to just come down to that env var in my case. I can set it to a profile that exists or unset it and the command will create a new profile OK.
In case it helps, my versions are:
aws-cli/2.0.8 Python/3.7.3 Linux/4.9.125-linuxkit botocore/2.0.0dev12
Hope that's useful! 馃

Thanks @ch-gareth I encountered this for aws-cli/1.16.115 Python/3.7.5 Darwin/17.7.0 botocore/1.12.105
and upgraded it to aws-cli/2.0.10 Python/3.7.4 Darwin/17.7.0 botocore/2.0.0dev14.

Was this page helpful?
0 / 5 - 0 ratings