pythonamazon-web-serviceslocalaws-lambda

How can I test lambda in local using python?


Is there any way that I can test aws lambda in local? I know there is a package which name is 'localstack' but seems like there is not many people who tried it.


Solution

  • You can run your Lambda functions in the same way you would run any python script e.g.

    if __name__ == "__main__":
        event = []
        context = []
        lambda_handler(event, context)
    

    If you use virtual environments, this helps ensure you have all the required dependencies installed for your lambda function alongside the correct python version.

    Is there any additional services you need that are present in 'localstack' that you don't have locally?