连接到Kinesis的其他AWS账户并从MQ放入记录

时间:2018-11-29 15:58:11

标签: python boto3 amazon-kinesis

我有以下代码,该代码应连接到Kinesis的不同AWS账户并放置来自AWS MQ的记录。

import time
import boto3
import json
from boto3 import Session

lambda_client = boto3.client('lambda')
kinesis_client = boto3.client('kinesis')

def lambda_handler(event, context):
    session = boto3.session.Session(aws_access_key_id= '', aws_secret_access_key= '',region_name='eu-aaa-1')
    kinesis_client = session.client('kinesis')
    print('received a message in worker : "%s"' % event)
    kinesis_client.put_record(
            StreamName='Stream_bookings',
            Data='event',
            PartitionKey='1'
        )

错误日志:-

{
  "errorMessage": "An error occurred (AccessDeniedException) when calling the PutRecord operation: User: arn:aws:iam::349928753634:user/svc.caspian-ingestion.onepurchase-uki-bookings-kinesis-test is not authorized to perform: kinesis:PutRecord on resource: arn:aws:kinesis:eu-central-1:349928753634:stream/CaspianStream_Onepurchase_UKI_bookings",
  "errorType": "ClientError",
  "stackTrace": [
    [
      "/var/task/op_worker.py",
      17,
      "lambda_handler",

我的政策:-

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "kinesis:PutRecord",
                "lambda:InvokeAsync",
                "lambda:InvokeFunction"
            ],
            "Resource": [
                "arn:aws:kinesis:eu-central-1:1234566789:stream/Stream_bookings"
            ]
        }
    ]
}

是否有可能在会话下传递Arn详细信息并发送记录

0 个答案:

没有答案