当我尝试在 aws 弹性搜索中注册存储库时出现错误“不允许跨账户传递角色”

Ham*_*aee 5 amazon-web-services amazon-iam amazon-cloudsearch

我在将存储库注册到 aws 弹性搜索时遇到问题。这是我用来执行此操作的链接:

[ http://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/es-managedomains-snapshots.html#es-managedomains-snapshot-registerdirectory][1]

正如链接中提到的,我复制了以下代码并运行它:

from boto.connection import AWSAuthConnection
Run Code Online (Sandbox Code Playgroud)

类 ESConnection(AWSAuthConnection):

def __init__(self, region, **kwargs):
    super(ESConnection, self).__init__(**kwargs)
    self._set_auth_region_name(region)
    self._set_auth_service_name("es")

def _required_auth_capability(self):
    return ['hmac-v4']

if __name__ == "__main__":

client = ESConnection(
        region='us-east-1',
        host='search-weblogs-etrt4mbbu254nsfupy6oiytuz4.us-east-1.es.example.com',
        aws_access_key_id='my-access-key-id',
        aws_secret_access_key='my-access-key', is_secure=False)

print 'Registering Snapshot Repository'
resp = client.make_request(method='POST',
        path='/_snapshot/weblogs-index-backups',
        data='{"type": "s3","settings": { "bucket": "es-index-backups","region": "us-east-1","role_arn": "arn:aws:iam::123456789012:role/TheServiceRole"}}')
body = resp.read()
print body
Run Code Online (Sandbox Code Playgroud)

我还调整了安全性和帐户 ID 以及……以适应我的情况。当我运行它时,我收到以下错误:

b'{"Message":"Cross-account pass role is not allowed."}'
Run Code Online (Sandbox Code Playgroud)

无论我使用什么都在同一个帐户中,我还向我的用户添加了以下内联策略

{
"Version": "2012-10-17",
"Statement": {
    "Effect": "Allow",
    "Action": "iam:PassRole",
    "Resource": "arn:aws:iam::xxxxxxxxxx:role/myrole"
}
Run Code Online (Sandbox Code Playgroud)

}

任何人都可以帮助我的问题是什么?