AWS Lambda:如何使用 Python 和命令行上传和测试代码
AWS Lambda: How To Upload & Test Code Using Python And Command Line
由于错误,我无法再使用内联编辑器编辑我的 AWS lambda 函数,"Your inline editor code size is too large. Maximum size is 51200."但是,我找不到解释如何从本地主机执行这些操作的演练:
- 将 python 脚本上传到 Lambda
- 向脚本提供 "event" 数据
- 查看 Lambda 输出
您需要为您的代码创建一个部署包,它只是一个 zip 存档,但具有特定的格式。说明在 the AWS Python deployment documentation.
中
然后您可以使用 context 对象为您的脚本提供事件数据,启动器信息在 AWS Python programming model documentation.
旁注:一旦您的 Lambda 代码开始变大,转移到某种管理框架通常会很方便。已经为 Lambda 编写了几个,我使用 Apex which is written in Go but works for any Lambda code, but you might be more comfortable with Gordon (has a great list of examples and is more active) or Kappa,它们都写在 Python.
由于错误,我无法再使用内联编辑器编辑我的 AWS lambda 函数,"Your inline editor code size is too large. Maximum size is 51200."但是,我找不到解释如何从本地主机执行这些操作的演练:
- 将 python 脚本上传到 Lambda
- 向脚本提供 "event" 数据
- 查看 Lambda 输出
您需要为您的代码创建一个部署包,它只是一个 zip 存档,但具有特定的格式。说明在 the AWS Python deployment documentation.
中然后您可以使用 context 对象为您的脚本提供事件数据,启动器信息在 AWS Python programming model documentation.
旁注:一旦您的 Lambda 代码开始变大,转移到某种管理框架通常会很方便。已经为 Lambda 编写了几个,我使用 Apex which is written in Go but works for any Lambda code, but you might be more comfortable with Gordon (has a great list of examples and is more active) or Kappa,它们都写在 Python.