【问题标题】:Sending records to cross account Kinesis stream from Lambda从 Lambda 向跨账户 Kinesis 流发送记录
【发布时间】:2020-12-07 12:54:46
【问题描述】:

我正在尝试使用来自“Account A”中的 Lambda fxn 的 boto3 api 将事件发送到另一个帐户(Account B)中的 kinesis 流

kinesis = boto3.client('kinesis', )

response = kinesis.put_record(
        StreamName="account-b-stream-name",
        Data=data,
        PartitionKey="partitionkey")

这会导致以下错误

An error occurred (AccessDeniedException) when calling the PutRecord operation: User: arn:aws:sts::<AccountA>:assumed-role/putrecords-staging-kinesis-dev-lambdaRole/putrecords-staging-kinesis-dev-hello is not authorized to perform: kinesis:PutRecord on resource: arn:aws:kinesis:eu-west-1:<AccountA>:stream/events_kinesis_staging

boto3 似乎将记录发送到 events_kinesis_staging 并假设它仍在运行 lambda 的 Account A 中。

如何明确指定流的帐户 ID。

【问题讨论】:

    标签: boto3 amazon-kinesis


    【解决方案1】:

    您可以在账户 B 中创建具有 Kinesis 权限的 IAM 用户。然后,创建访问密钥。

    然后在您的 lambda 函数中,您可以添加环境变量 AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEY 并输入访问键中的值。这应该能让你继续前进。

    但是,更好的方法是设置跨账户委派角色。 https://docs.aws.amazon.com/IAM/latest/UserGuide/tutorial_cross-account-with-roles.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-25
      • 1970-01-01
      • 2019-05-09
      • 1970-01-01
      • 2018-01-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多