简体   繁体   English

使用 Python 测试 AWS lambda

[英]Testing AWS lambdas using Python

We have AWS lambdas written in Python and I need to test them.我们有用 Python 编写的 AWS lambda,我需要测试它们。 We'll be using API gateway, S3 and other services for building the application.我们将使用 API 网关、S3 和其他服务来构建应用程序。

SNS will trigger the lambdas. SNS 将触发 lambdas。 I've some basic knowledge of Python and I'm able to invoke the lambdas using boto3.我对 Python 有一些基本的了解,并且能够使用 boto3 调用 lambda。 I've heard of package moto to mock S3 and other services but do we need all code locally to use this package?我听说过使用 moto 包来模拟 S3 和其他服务,但是我们是否需要在本地使用所有代码才能使用此包?

Could you please suggest the best strategy for testing?你能建议最好的测试策略吗? Should we test them locally if yes then how can we do that?如果是,我们是否应该在本地测试它们,那么我们该怎么做呢?

It will be really nice if you can give any reference or example.如果您可以提供任何参考或示例,那将非常好。

Thanks a lot!非常感谢!

Regards, Sunil问候, 苏尼尔

you can test your lambda locally using serverless or SAM CLI ,您可以使用无服务器SAM CLI在本地测试您的 lambda,

Find more information here SAM CLI , Serverless在此处查找更多信息SAM CLI , Serverless

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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