我有一个Python Lambda函数,它将从AWS MQ发送消息到相同AWS账户的AWS Kinesis。 如果我在不同的AWS账户中拥有运动能力,如何实现相同的目标?
import time
import boto3
import stomp
import json
kinesis_client = boto3.client('kinesis')
class Listener(stomp.ConnectionListener):
def on_error(self, headers, message):
print('received an error "%s"' % message)
kinesis_client.put_record(
StreamName='',
Data=u'{}\r\n'.format(message).encode('utf-8'),
PartitionKey='0'
)
def on_message(self, headers, message):
print('received a message "%s"' % message)
def lambda_handler(event, context):
conn = stomp.Connection(host_and_ports=[('', 61614)])
lst = Listener()
conn.set_listener('Listener', lst)
conn.set_ssl(for_hosts=[('', 61614)])
conn.start()
print('CONNECTION Started')
conn.connect(login='', passcode='',wait=True)
print('CONNECTION established')
conn.subscribe(destination='/queue/', id=1, ack='auto')
print('CONNECTION Subscribed')
time.sleep(10)
conn.disconnect()
return
谢谢