5

这是我尝试将文档上传到云搜索的代码

from boto.cloudsearch2.layer2 import Layer2
conn_config = {
    'region': 'us-east-1',
    'aws_access_key_id': os.getenv('AWS_ACCESS'),
    'aws_secret_access_key': os.getenv('AWS_SECRET'),
    'debug': 2
}
conn = Layer2(**conn_config)
domain = conn.lookup(my_domain)
doc_service = domain.get_document_service()
doc_service.add(my_id, my_fields)
doc_service.commit()

这是我得到的错误:

Traceback (most recent call last):
line 32, in <module> doc.commit()
File "/Library/Python/2.7/site-packages/boto/cloudsearch2/document.py", line 205, in commit return CommitResponse(r, self, sdf)
File "/Library/Python/2.7/site-packages/boto/cloudsearch2/document.py", line 250, in      __init__
self.adds = self.content['adds']
KeyError: 'adds'

我认为这是一个误导性错误。当我将此行添加到/Library/Python/2.7/site-packages/boto/cloudsearch2/document.py的init ()

print self.content

真正的问题似乎表现为:

{u'status': u'error', u'message': u'User: anonymous is not authorized to perform:    cloudsearch:document on resource: arn:aws:cloudsearch:us-east-1:053216739513:domain/dev-audit', u'errors': [{u'message': u'[*Deprecated*: Use the outer message field] User: anonymous is not authorized to perform: cloudsearch:document on resource: arn:aws:cloudsearch: ...'}], u'__type': u'#AccessDenied'}

关于如何克服这个恼人的权限错误的任何见解?我可以使用给定的访问 ID 和密钥进行搜索,但无法上传!!!

4

1 回答 1

5

CloudSearch 允许您为查询和文档提交配置单独的访问策略。听起来您的文档提交策略可能比您的查询策略(这是一种常见设置)更具限制性。

您可以让文档提交完全开放以测试事物,稍后使用http://docs.aws.amazon.com/cloudsearch/latest/developerguide/configuring-access.html上的指南提出访问策略。

示例全开配置:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "",
      "Effect": "Allow",
      "Principal": {
        "AWS": "*"
      },
      "Action": "cloudsearch:*"
    }
  ]
}

以下是 AWS Web 控制台中的去处:

CloudSearch 访问策略

于 2014-10-24T15:36:15.817 回答