【问题标题】:mod_wsgi and aws access keysmod_wsgi 和 aws 访问密钥
【发布时间】:2018-01-30 21:48:14
【问题描述】:

我有一个在 Apache 和 mod_wsgi 下运行的 Flask 应用程序。 它需要从 AWS S3 读取,所以我使用 boto3。 我所做的是运行 aws configure 来创建 ~/.aws 然后将其移至 为 WSGI 配置的 home。但是当我运行应用程序时,我得到:

botocore.exceptions.ClientError: An error occurred (AccessDenied) when calling the ListBuckets operation: Access Denied

如果我将 WSGI 应用程序启动文件中的键设置为 os.environ['AWS_....'] = ... 它可以正常工作。

那么问题是如何利用在 mod_wsgi 下运行的 Flask 应用程序的 aws configure 输出?

【问题讨论】:

    标签: python amazon-web-services amazon-s3 mod-wsgi boto3


    【解决方案1】:

    在操作系统级别设置 AWS_PROFILE 环境变量。在 Linux 中,您将在 '/etc/environment' 中创建变量

    AWS_PROFILE=myprofile

    或者,您可以为实例配置文件创建一个 IAM 角色并以这种方式提供适当的权限。

    【讨论】:

    • 但是为什么boto3从WSGI模块运行时看不到./aws的内容呢?
    猜你喜欢
    • 1970-01-01
    • 2019-10-10
    • 2017-03-23
    • 2020-12-14
    • 1970-01-01
    • 2021-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多