可以跨账户访问 AWS DynamoDB 流吗?

It is possible to Access AWS DynamoDB streams accross accounts?

我的公司使用多账户系统管理 AWS。我在账户 A 中有一个 lambda 函数,在账户 B 中有一个启用了 Stream 的 DynamoDB table。我希望流事件触发我的函数。

当我运行:

aws lambda create-event-source-mapping --event-source-arn arn:aws:dynamodb:us-east-1:101010101:table/table/stream/2016-08-09T23:00:46.852 --function-name Lambda-qa --enabled --batch-size 10 --starting-position TRIM_HORIZON

我收到以下错误: 调用CreateEventSourceMapping操作时出现错误(InvalidParameterValueException):角色和事件源必须与云函数在同一个账户

看起来 Lambda 函数和 DynamoDB 流必须在同一个帐户中。但是可以通过其他方式从accountB读取accountA中的DynamoDB流吗?重定向、SNS、SQS、S3 或自定义应用程序。

很遗憾,没有。

来自 AWS 文档:

“重要

您必须在创建 Lambda 函数的同一区域中创建 DynamoDB table。本教程假设美国东部(弗吉尼亚北部)区域。 此外,table和Lambda函数必须属于同一个AWS账户

(强调)

参考: http://docs.aws.amazon.com/lambda/latest/dg/with-ddb-configure-ddb.html

由于 DynamoDB 在后端使用 Kinesis 用于其流,您无法在 DynamoDB table 和 lambda 之间创建跨账户事件源映射。

这在 AWS 的以下博客 post 中有记录:

How do I invoke my Lambda function using a cross-account Kinesis stream?

Lambda doesn't currently support cross-account triggers from Kinesis or any stream-based sources.

博客post也提供了解决方法:

As a workaround, you can use a "poller" Lambda function in the same account as the Kinesis stream (account A) to invoke a "processor" Lambda function in the other account (account B).