1

我正在按照本教程将我的所有 DynamoDB 流自动索引到我创建的 Amazon ElasticSearch 服务集群中。

我一步一步地遵循它,并创建了所有权限策略。

但是,当我进行测试时,我的 Amazon ES 集群中没有任何索引。当我检查 CloudWatch 时,我会看到以下日志:

('ERROR: ', 'Traceback (most recent call last):
 File "/var/task/lambda_function.py", line 123, in lambda_handler
 return _lambda_handler(event, context)
 File "/var/task/lambda_function.py", line 219, in _lambda_handler
 post_to_es(es_payload) # post to ES with exponential backoff
 File "/var/task/lambda_function.py", line 86, in post_to_es
 es_ret_str = post_data_to_es(payload, es_region, creds, es_endpoint, \'/_bulk\')
 File "/var/task/lambda_function.py", line 53, in post_data_to_es
 req = botocore.awsrequest.create_request_object(params)
 File "/var/runtime/botocore/awsrequest.py", line 314, in create_request_object
 request_object.context.update(r[\'context\'])
KeyError: \'context\'
')

我不明白这个问题。我只知道我的 Lambda 函数成功触发了每个 DynamoDB 流并且可以将日志发送到 CloudWatch,但无法在 Amazon ES 中索引这些数据。

有人可以帮我解决这个问题吗?

4

1 回答 1

0

aws lambda 使用的 botocore 代码最近发生了重大变化。

受影响的代码行是:
req = botocore.awsrequest.create_request_object(params)

随着新的变化,他们期望参数参数包含“上下文”字段。

因此,请将上下文字段添加到您的 params 参数中:示例:params = {'method': method, 'url': proto + host + path, 'region': region, 'headers': {'Host': host}, 'body': payload,'context': {'signing': {'region': 'us-east-1'}}}

进行上述更改后,您的 lambda 应该能够成功运行。

详细信息:在文件 botocore.awsrequest 中,第 314 行的代码更改导致了此问题。 https://github.com/boto/botocore/commit/28b8831f5f8518bef5accf994fc377c58a3569f7#diff-cb00fc815f8f80ae15e7d0cecc74b395

于 2016-08-03T07:38:20.800 回答