python - 连接到 Kinesis 的不同 AWS 账户并从 MQ 中放入记录
问题描述
我有下面的代码应该连接到 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 详细信息并发送记录
解决方案
推荐阅读
- node.js - Redis:ioredis 与 lua 脚本
- regex - CloudFormation 参数动态正则表达式
- jupyter-notebook - 构建 Jupyter Notebook 时,nbsphinx 导致构建失败
- gekko - 具有自由终止时间的最优控制 (gekko)
- java - 是否可以让 android 设备尝试连接到之前已连接的任何可用网络?
- javascript - 无法为来自 Selenium Java 的某些 HTML 输入放置超过一个字符的文本
- mongodb - 在 pymongo 中触发
- c# - 如何在 WASM 运行时中运行 UnitTest
- laravel - 存储多态 belongsTo 关系的最佳实践
- r - 删除数据框中包含特定值的因子列