2

I am working in AWS Lambda Function with python (boto3) for decrypting a key that I am getting from the Cognito to my lambda function as an event parameter (in encrypted format). I have set the KMS symmetric key for encryption and decryption. But it still has the error. It is necessary for me to implement the 3rd party OTP service in my microservice-based project on AWS and I have tried in different ways. Here is my lambda code:

import json
import os
import base64
import urllib
import boto3

def lambda_handler(event, context):
    encrypted_code = event['request']['code']
    print("encrypted_code", encrypted_code)
    
    session = boto3.session.Session()
    client = session.client('kms')
    
    # DECRYPT THE ENCODED CODE
    decrypted = client.decrypt(CiphertextBlob=base64.b64decode(encrypted_code))
    print(decrypted['Plaintext'])
    
md jakaria
  • 75
  • 1
  • 7

0 Answers0