gpt4 book ai didi

amazon-web-services - 通过 kinesis 触发跨账户 lambda

转载 作者:行者123 更新时间:2023-12-02 02:16:05 27 4
gpt4 key购买 nike

我正在尝试通过帐户“A”中的 Kinesis 流触发帐户“B”中的 lambda。这与 here 中的描述类似。 ,但示例使用 S3 而不是 Kinesis。

为此,我尝试设置正确的权限,但遇到了困难。

首先我添加此权限:

  aws lambda add-permission \
--function-name "$function_name" \
--statement-id 'Id-123' \
--action "lambda:InvokeFunction" \
--principal $source_account \
--source-arn "$stream_arn" \
--source-account $source_account \
--region us-east-1 \
--profile "$profile"

其中 $source_account 是“A”的帐户 ID。

然后我尝试创建源映射:

 aws lambda create-event-source-mapping \
--event-source-arn "$stream_arn" \
--function-name "$function_name" \
--starting-position TRIM_HORIZON \
--region us-east-1 \
--profile "$profile"

我收到以下错误:

A client error (InvalidParameterValueException) occurred when calling the CreateEventSourceMapping operation: Role and event source must be in the same account as the cloud function

我不明白这个错误。这是在说我想做的事情是不可能的吗?但它是如何实现的here与S3,本质上是相同的机制?

最佳答案

Amazon Kinesis 流的 AWS Lambda 函数仅当两者位于同一账户中时才有效。

如果您想调用账户 B 中的函数,您可以将账户 A 中部署的扇出函数挂接到账户 A 中的流,并要求它以跨账户角色调用账户 B 中的函数。创建一个Lambda 类型的目标并指定账户 B 中的角色。

关于amazon-web-services - 通过 kinesis 触发跨账户 lambda,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42448960/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com