Python AWS:找不到配置文件 (MyName)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34134879/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
AWS : The config profile (MyName) could not be found
提问by Steve Ritz
Every time I want to config something with AWS I get the following error :
每次我想用 AWS 配置一些东西时,我都会收到以下错误:
"The config profile (myname) could not be found"
like : aws configure
喜欢:aws 配置
I'm using Python 3.4 and I want to use AWS CLI Keyring to encrypt my credentials..
我正在使用 Python 3.4 并且我想使用 AWS CLI Keyring 来加密我的凭证。
采纳答案by Stanley Yong
I think there is something missing from the AWS documentation in http://docs.aws.amazon.com/lambda/latest/dg/setup-awscli.html, it did not mention that you should edit the file ~/.aws/config
to add your username profile. There are two waysto do this:
我认为http://docs.aws.amazon.com/lambda/latest/dg/setup-awscli.html 中的 AWS 文档中缺少一些内容,它没有提到您应该编辑该文件~/.aws/config
以添加您的用户名配置文件. 有两种方法可以做到这一点:
edit
~/.aws/config
oraws configure --profile "your username"
编辑
~/.aws/config
或aws configure --profile "your username"
回答by Frederic Henri
can you check your config
file under ~/.aws/config
- you might have an invalid section called [myname], something like this (this is an example)
你能检查下你的config
文件~/.aws/config
吗 - 你可能有一个名为 [myname] 的无效部分,像这样(这是一个例子)
[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
只需删除 [myname] 部分(包括此配置文件的所有内容),您就可以aws
再次运行cli
回答by Saravanakumar Karunanithi
Use as follows
使用如下
[profilename]
region=us-east-1
output=text
Example cmd
示例命令
aws --profile myname CMD opts
回答by Mike Pinnell
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..
你真的设置了你的特定用户吗?AWS 中的演练设置指南解释了如何设置默认用户,以及如何设置其他用户。如果您没有完成完整的设置,您将只有一个默认块,而您的 myName 将不会被创建。
回答by shekharlondhe
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.
面临类似的问题,发现下面的链接比此处提供的答案更有帮助。我猜这是由于提供了答案后对 AWS CLI 进行了更新。
https://serverfault.com/questions/792937/the-config-profile-adminuser-could-not-be-found
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).
从本质上讲,它有助于创建两个不同的文件(即一个用于一般配置相关信息,第二个用于凭据相关信息)。
回答by billkw
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:
当我搬到一台新机器上时遇到了这个问题,我带着我的 AWS_DEFAULT_PROFILE 环境变量,但不是我的 ~/.aws 目录。在我取消设置该变量或正确配置命名配置文件之前,我无法使用任何 awscli 命令。但是连aws configure
命令都被破坏了,让事情变得有点棘手。假设您有一个方便的类 Unix 外壳:
- 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
- 要确定您的会话中可能包含哪些 AWS 特定变量:
env | grep AWS_
- 如果您没有看到此处列出的 AWS_DEFAULT_PROFILE,则此答案不适用于您。
- 暂时删除默认配置文件:
unset AWS_DEFAULT_PROFILE
- 要配置该默认配置文件:
aws --profile foo configure
- 要重置默认配置文件变量:
exec $SHELL
- 要测试您的新设置:
aws iam get-user
回答by owenfi
For me it was because I had my .aws/config
file looking like this:
对我来说,这是因为我的.aws/config
文件看起来像这样:
[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.
我认为原因是我基于我的.aws/credentials
文件,这需要[profile myname]
Zappa 和其他一些 aws/elastic beanstalk 工具。
When I changed config
to this it worked great:
当我改成config
这个时,效果很好:
[myname]
aws_access_key_id = ....
aws_secret_access_key = ....
region=us-west-1
回答by andyw
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.
确保您在正确的 VirtualEnvironment 中。我更新了 PyCharm,出于某种原因不得不再次将我的项目指向我的 VE。打开终端,尝试 zappa 更新时我不在我的 VE 中(并出现此错误)。重启PyCharm,一切恢复正常。
回答by user6058180
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)
使用配置文件有点棘手。文档可以在以下位置找到:https: //docs.aws.amazon.com/cli/latest/topic/config-vars.html(但您需要注意像 AWS_PROFILE 这样的 env 变量)
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:
`
将配置文件与 aws cli 一起使用需要一个配置文件(默认为 at~/.aws/config
或使用 设置AWS_CONFIG_FILE
)。供参考的示例配置文件:`
[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
.
环境变量AWS_PROFILE
通知 AWS cli 有关要从 AWS config 使用的配置文件的信息。它不是像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
.
另一个有趣的事实是,如果AWS_PROFILE
设置了AWS_ACCESS_KEY_ID
和AWS_SECRET_ACCESS_KEY
环境变量,则由AWS_ACCESS_KEY_ID
和提供的凭据AWS_SECRET_ACCESS_KEY
将覆盖位于由 提供的配置文件中的凭据AWS_PROFILE
。