简体   繁体   中英

How to decrypt data received from kinesis in AWS lambda

I have configured my lambda to get triggered from AWS kinesis.

The handler receives the event and i get the log in cloudwatch as below:

{'Records': [{'kinesis': {'kinesisSchemaVersion': '1.0', 'partitionKey': 'MSFT', 'sequenceNumber': '49626331424383135829970932456737647485340372651235868706', 
'data': 'eyJwcmljZV90aW1lc3RhbXAiOiAiMjAyMS0wMi0wMSAwOTozMDowMC0wNTowMCIsICJzdG9ja2lkIjogIk1TRlQiLCAicHJpY2UiOiAyMzUuMCwgIndlZWs1Mm1heCI6IDM0OS42NzAwMTM0Mjc3MzQ0LCAid2VlazUybWluIjogMjI3LjE3OTk5MjY3NTc4MTI1fQ==', 'approximateArrivalTimestamp': 1643650596.425}, 'eventSource': 'aws:kinesis', 'eventVersion': '1.0', 'eventID': 'shardId-000000000002:49626331424383135829970932456737647485340372651235868706', 'eventName': 'aws:kinesis:record', 'invokeIdentityArn': 'arn:aws:iam::799034532258:role/kinesis_sns_dynamodb', 'awsRegion': 'us-east-1', 'eventSourceARN': 'arn:aws:kinesis:us-east-1:799034532258:stream/stock_streams'}, {'kinesis': {'kinesisSchemaVersion': '1.0', 'partitionKey': 'MSFT', 'sequenceNumber': '49626331424383135829970932456972179094345617239479156770', 'data': 'eyJwcmljZV90aW1lc3RhbXAiOiAiMjAyMS0wMi0wMSAxMDozMDowMC0wNTowMCIsICJzdG9ja2lkIjogIk1TRlQiLCAicHJpY2UiOiAyMzcuOTc5OTk1NzI3NTM5MDYsICJ3ZWVrNTJtYXgiOiAzNDkuNjcwMDEzNDI3NzM0NCwgIndlZWs1Mm1pbiI6IDIyNy4xNzk5OTI2NzU3ODEyNX0=', 'approximateArrivalTimestamp': 1643650691.538}, 'eventSource': 'aws:kinesis', 'eventVersion': '1.0', 'eventID': 'shardId-000000000002:49626331424383135829970932456972179094345617239479156770', 'eventName': 'aws:kinesis:record', 'invokeIdentityArn': 'arn:aws:iam::799034532258:role/kinesis_sns_dynamodb', 'awsRegion': 'us-east-1', 'eventSourceARN': 'arn:aws:kinesis:us-east-1:799034532258:stream/stock_streams'}, {'kinesis': {'kinesisSchemaVersion': '1.0', 'partitionKey': 'MSFT', 'sequenceNumber': '49626331424383135829970932456979432649263312367511404578', 'data': 'eyJwcmljZV90aW1lc3RhbXAiOiAiMjAyMS0wMi0wMSAwOTozMDowMC0wNTowMCIsICJzdG9ja2lkIjogIk1TRlQiLCAicHJpY2UiOiAyMzUuMCwgIndlZWs1Mm1heCI6IDM0OS42NzAwMTM0Mjc3MzQ0LCAid2VlazUybWluIjogMjI3LjE3OTk5MjY3NTc4MTI1fQ==', 'approximateArrivalTimestamp': 1643650799.27}, 'eventSource': 'aws:kinesis', 'eventVersion': '1.0', 'eventID': 'shardId-000000000002:49626331424383135829970932456979432649263312367511404578', 'eventName': 'aws:kinesis:record', 'invokeIdentityArn': 'arn:aws:iam::799034532258:role/kinesis_sns_dynamodb', 'awsRegion': 'us-east-1', 'eventSourceARN': 'arn:aws:kinesis:us-east-1:799034532258:stream/stock_streams'}]}

Not sure, how to retrive back my data. I am sure, its encrypyted in "data" attribute in the above received json.

I am woking in python. Any idea how to decrypt my data in lambda_handler?

Thanks, Nilotpal

That's not encrypted, it's Base64 encoded. The official documentation includes example Python code to decode the data payload.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM