我试图让我的 lambda 函数在 AWS 中运行。我正在使用 PyAlexa 技能工具包。
我使用 PyAlexa Skill 工具包为 Alexa 创建了一个测试技能。该工具包只是为您创建 aws lambda 函数所需的必要文件和结构。它还会生成一些基本的测试话语和示例意图文件,以帮助您入门。
我遇到的问题是 aws lambda 函数。我注意到该脚本使用deployment_n 压缩所有内容,其中n 是文件名前面的增量编号,我假设它是一个版本。然后有一个 main.py 和一个 AlexaHandler.py 文件。它还包括 pyalexa-skill 和版本的文件。
我遇到的问题是我对 main.py 中的基本处理程序的主要调用返回了一个错误,即 main 的模块不存在。经过调查,它说这是一个命名问题,所以我对问题出在哪里感到困惑。我已经尝试过 deployment_1main.lambda_function 并且我已经尝试过 main.lambda_function 所以我不确定它是如何命名错误的。有什么想法吗?
包装上的视频在这里:
https://www.youtube.com/watch?v=O-NaTeq_35s
我的 main.py 代码
import logging
from AlexaHandler import AlexaDeploymentTestHandler
# Main entry point for the Lambda function.
# In the AWS Lamba console, under the 'Configuration' tab there is an
# input field called, 'Handler'. That should be: main.lambda_handler
# Handler: main.lambda_handler
# Role: lambda_basic_execution
logger = logging.getLogger()
logger.setLevel(logging.INFO)
def lambda_handler(event, context):
logging.info("Executing main lambda_handler for YourDeploymentHandler class")
deployment_handler = AlexaDeploymentTestHandler()
handler_response = deployment_handler.process_request(event, context)
return handler_response