[python] AWS : The config profile (MyName) could not be found

Every time I want to config something with AWS I get the following error :

"The config profile (myname) could not be found"

like : aws configure

I'm using Python 3.4 and I want to use AWS CLI Keyring to encrypt my credentials..

This question is related to python amazon-web-services credentials aws-cli

The answer is


In my case, I had the variable named "AWS_PROFILE" on Environment variables with an old value.

enter image description here


In my case, I was using the Docker method for the AWS CLI tool, and I hadn't read the instructions far enough to realize that I had to make my credentials directory visible to the docker container. https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-docker.html

Instead of

docker run --rm -it amazon/aws-cli:latest command args...

I needed to do:

docker run --rm -it -v ~/.aws:/root/.aws amazon/aws-cli:latest command args...


Did you actually set up your specific user? The walkthrough setup guide in AWS explains how to set a default user, and then how to set up additional users. If you didn't complete the full setup, you'll just have a default block and your myName won't have been created..


can you check your config file under ~/.aws/config- you might have an invalid section called [myname], something like this (this is an example)

[default]
region=us-west-2
output=json

[myname]
region=us-east-1
output=text

Just remove the [myname] section (including all content for this profile) and you will be fine to run aws cli again


For me it was because I had my .aws/config file looking like this:

[profile myname]
aws_access_key_id = ....
aws_secret_access_key = ....
region=us-west-1

I think the reason is I based it off my .aws/credentials file, which requires having [profile myname] for Zappa and maybe some other aws/elastic beanstalk tools.

When I changed config to this it worked great:

[myname]
aws_access_key_id = ....
aws_secret_access_key = ....
region=us-west-1

Make sure you are in the correct VirtualEnvironment. I updated PyCharm and for some reason had to point my project at my VE again. Opening the terminal, I was not in my VE when attempting zappa update (and got this error). Restarting PyCharm, all back to normal.


I ran into this problem when I moved to a new machine, carrying with me my AWS_DEFAULT_PROFILE environment variable, but not my ~/.aws directory. I couldn't get any awscli commands to work until I unset that variable or properly configured the named profile. But even the aws configure command was broken, making things a bit tricky. Assuming you have a Unix-like shell handy:

  • To determine what AWS-specific variables you might have in your session: env | grep AWS_
    • if you don't see AWS_DEFAULT_PROFILE listed here, this answer is not applicable to you.
  • To temporarily remove the default profile: unset AWS_DEFAULT_PROFILE
  • To configure that default profile: aws --profile foo configure
  • To reset the default profile variable: exec $SHELL
  • To test your new setup: aws iam get-user

Was facing similar issue and found below link more helpful then the answers provided here. I guess this is due to the updates to AWS CLI since the answers are provided.

https://serverfault.com/questions/792937/the-config-profile-adminuser-could-not-be-found

Essentially it helps to create two different files (i.e. one for the general config related information and the second for the credentials related information).


Use as follows

[profilename]
region=us-east-1
output=text

Example cmd

aws --profile myname CMD opts

Working with profiles is little tricky. Documentation can be found at: https://docs.aws.amazon.com/cli/latest/topic/config-vars.html (But you need to pay attention on env variables like AWS_PROFILE)

Using profile with aws cli requires a config file (default at ~/.aws/config or set using AWS_CONFIG_FILE). A sample config file for reference: `

[profile PROFILE_NAME]
 output=json
 region=us-west-1
 aws_access_key_id=foo
 aws_secret_access_key=bar

`

Env variable AWS_PROFILE informs AWS cli about the profile to use from AWS config. It is not an alternate of config file like AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY are for ~/.aws/credentials.

Another interesting fact is if AWS_PROFILE is set and the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables are set, then the credentials provided by AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY will override the credentials located in the profile provided by AWS_PROFILE.


Examples related to python

programming a servo thru a barometer Is there a way to view two blocks of code from the same file simultaneously in Sublime Text? python variable NameError Why my regexp for hyphenated words doesn't work? Comparing a variable with a string python not working when redirecting from bash script is it possible to add colors to python output? Get Public URL for File - Google Cloud Storage - App Engine (Python) Real time face detection OpenCV, Python xlrd.biffh.XLRDError: Excel xlsx file; not supported Could not load dynamic library 'cudart64_101.dll' on tensorflow CPU-only installation

Examples related to amazon-web-services

How to specify credentials when connecting to boto3 S3? Is there a way to list all resources in AWS Access denied; you need (at least one of) the SUPER privilege(s) for this operation Job for mysqld.service failed See "systemctl status mysqld.service" What is difference between Lightsail and EC2? AWS S3 CLI - Could not connect to the endpoint URL boto3 client NoRegionError: You must specify a region error only sometimes How to write a file or data to an S3 object using boto3 Missing Authentication Token while accessing API Gateway? The AWS Access Key Id does not exist in our records

Examples related to credentials

git clone: Authentication failed for <URL> How to save username and password in Git? AWS : The config profile (MyName) could not be found Remove credentials from Git Configuring user and password with Git Bash SVN change username HttpWebRequest using Basic authentication Using cURL with a username and password? How do I find my host and username on mysql? How to Specify Eclipse Proxy Authentication Credentials?

Examples related to aws-cli

The AWS Access Key Id does not exist in our records AWS CLI S3 A client error (403) occurred when calling the HeadObject operation: Forbidden How can I resolve the error "The security token included in the request is invalid" when running aws iam upload-server-certificate? AWS : The config profile (MyName) could not be found Error You must specify a region when running command aws ecs list-container-instances Downloading an entire S3 bucket?