Amazon boto.mws 与 IAM 角色和配置文件的连接

Amazon boto.mws connection with IAM roles and profiles

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

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

当我使用其他 Amazon 服务(例如 SQS)时,我已经能够使用 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)

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

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 角色使用亚马逊的 boto SDK 连接到 MWS?

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