How can I test lambda in local using python?

user6922072 picture user6922072 · Mar 30, 2017 · Viewed 10.8k times · Source

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.

Answer

apoclyps picture apoclyps · Mar 30, 2017

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?