def get_encryption_aes_key(key, kms_client): encryption_context = {"kms_cmk_id": key} response = kms_client.generate_data_key( KeyId=key, EncryptionContext=encryption_context, KeySpec="AES_256" ) return ( response["Plaintext"], encryption_context, base64.b64encode(response["CiphertextBlob"]).decode(), )