【问题标题】:AWS credentials : unable to locate credentials in django pythonAWS 凭证:无法在 django python 中找到凭证
【发布时间】:2017-04-12 05:55:57
【问题描述】:

我已经使用 aws configure 配置了凭据。 aws configure list 看起来不错。Python/django 能够在 shell_plus 中找到凭据,但在通过 gunicorn/supervisor 运行 django 时无法找到凭据。

这很奇怪

【问题讨论】:

  • 请分享代码,以获得更多说明
  • 嗨,它与代码无关。当以 ubuntu 用户身份运行 gunicorn 时,它正在获取凭据,但使用 supervisorctl 运行 gunicorn 却没有
  • 凭证在哪里?它们是环境变量吗?
  • 检查你的gunicorn /supervisor使用的用户环境。否则,您必须让它们指向您使用 aws configure 设置访问权限的用户。

标签: python django amazon-web-services boto3


【解决方案1】:

当您运行 aws configure 时,您将编写链接到您的配置文件的文件,因为它们将写入 ~/.aws/config 和 ~/.aws/credentials。

当您运行应用程序时,应用程序将使用相同的逻辑查找这些文件,即.~/.aws/credentials。

在 shell 中时,解释器会尝试将 ~ 转换为基于 $(whoami) 的绝对路径。

TL;DR - 您必须使用与运行应用程序相同的用户运行 aws configure。

【讨论】:

    猜你喜欢
    • 2019-06-01
    • 2021-09-29
    • 2022-12-16
    • 1970-01-01
    • 1970-01-01
    • 2021-09-13
    • 1970-01-01
    • 1970-01-01
    • 2014-04-10
    相关资源
    最近更新 更多