【问题标题】:Amazon boto.mws connection with IAM roles and profilesAmazon boto.mws 与 IAM 角色和配置文件的连接
【发布时间】:2017-02-15 11:20:11
【问题描述】:

我一直在尝试连接到 Amazon 的 boto SDK 以构建连接到 Amazon 的 MWS 服务的连接器。

但是,现在,我能够向 boto.mws.connection 的 MWSConnection 类提供我的凭据的唯一方法是硬编码访问密钥和密钥。显然这不适合部署。

当我使用 SQS 等其他 Amazon 服务时,我已经能够使用 IAM 角色和配置文件进行连接。例如,下面是一些我用来通过配置文件连接到 SQS 的示例代码:

REGION = "us-west-2"
PROFILE_NAME = 'my_profile'

class SQSManager(object):

    def __init__(self):
        self.conn = boto.sqs.connect_to_region(region_name=REGION, profile_name=PROFILE_NAME)

但是,我还没有找到通过 MWS 的 profile_name 进行连接的方法。我搜索了 MWSConnection 类的方法,这就是它实例化连接的方式:

class MWSConnection(AWSQueryConnection):

    ResponseFactory = boto.mws.response.ResponseFactory
    ResponseErrorFactory = boto.mws.exception.ResponseErrorFactory

    def __init__(self, *args, **kw):
        kw.setdefault('host', 'mws.amazonservices.com')
        self._sandboxed = kw.pop('sandbox', False)
        self.Merchant = kw.pop('Merchant', None) or kw.get('SellerId')
        self.SellerId = kw.pop('SellerId', None) or self.Merchant
        kw = self._setup_factories(kw.pop('factory_scopes', []), **kw)
        super(MWSConnection, self).__init__(*args, **kw)

它显然接受访问/密钥是关键字参数。无论如何使用配置文件和 IAM 角色使用 Amazon 的 boto SDK 连接到 MWS?

【问题讨论】:

    标签: python-2.7 amazon-web-services boto


    【解决方案1】:

    Marketplace Web Service (MWS) 是亚马逊零售。我认为它与 AWS 没有任何关系,而且它根本不使用 IAM。看到 boto 支持它,我真的很惊讶(它是 not in boto3)。

    【讨论】:

      猜你喜欢
      • 2018-06-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-26
      • 2018-07-09
      • 2016-08-27
      • 2019-08-06
      • 2023-03-03
      相关资源
      最近更新 更多