How do I run a run test on lambda?

Asked 2 years ago, Updated 2 years ago, 114 views

When running lambda, you often waste your time getting hooked on subtle behavior to behave slightly differently than when you run the handler directly.

I am trying to run python with lambda, but I have encountered the following behavior, for example:

  • The package cannot be imported because the pip package is not included in the deployment destination
  • Error when file permission is 600 and lambda cannot read and import with this permission
  • Logging module behavior is different from hand (under investigation)

and so on.

Deploying to lambda, running ahead, and retrieving logs from the cloud watch, etc., is laborious.

Is there any way to test lambda's running environment locally (as much as possible)?

python aws aws-lambda

2022-09-30 19:55

2 Answers

emulambda is present.
It's not from Amazon, it seems to be made by Fugue.

Google Cloud Functions is officially Google Cloud Functions Emulator.
(Oh, I put it out because it's similar, but it wasn't Python.Google App Engine also officially offers a local environment)


2022-09-30 19:55

How about sam cli?I actually use it, but it's very convenient.
The sample launches Lambda from APIGatway, but both Lambda alone and via API can be tested smoothly.
What is the AWS Serverless Application Model (AWS SAM)?

Local debugging and testing. - AWS SAMCLI allows serverless applications to be built, tested, and debugged locally.AWS SAM template.The CLI provides a running environment like Lambda locally.Providing the same functionality as the actual Lambda running environment can help you understand the problem ahead of time.To step through and debug code and understand what code is doing, the AWS SAM toolkit for JetBrains, AWSToolkit for PyCharm, AWSToolkit for IntelliJ, and AWSToolkit for Visual Studio Code can help you find and troubleshoot problems that may occur on the cloud and

How it works is when testing or debugging locally, the runtime or self-prepared container image (specifying Dockerfile) container is started and the function is executed.The tutorial is an example of runtime, so only the default library (such as boto3) works unless you import a library.
Tutorial: Deploying Hello World Applications


2022-09-30 19:55

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.