How to setup PyCharm to develop AWS Lambda function on local machine?

10,644

Solution 1

As of the announcement at the re:Invent 2018 keynote, Jetbrains now offers the AWS Toolkit which allows local and remote development of Lambda functions.

Despite some lingering issues it works quite well.

User exan has provided the link on AWS' site here

There is also a blog post when using PyCharm on MacOS

Toolkit page on Jetbrains website

UPDATE April 2019: Jetbrains has been very responsive and active in fixing any issues. Issues with credentials and templates seem resolved and it's quite a joy to work with.

Solution 2

Directly go through the page-> https://medium.com/@bezdelev/how-to-test-a-python-aws-lambda-function-locally-with-pycharm-run-configurations-6de8efc4b206

pip install python-lambda-local
python-lambda-local -f lambda_handler lambda_function.py event.json
Share:
10,644
exan
Author by

exan

Updated on June 15, 2022

Comments

  • exan
    exan almost 2 years

    I am looking forward to developing some AWS lambda functions in python using PyCharm. How can I setup my IDE to develop and test the function locally? Can experts guide how to set it up? Any links or relevant tutorials will be really helpful.

  • exan
    exan over 5 years
    Thanks, and here is the link from AWS with detailed discussion and documentation
  • Camillo
    Camillo over 5 years
    I've explained how to set up your local macOS development environment and how to set up PyCharm to test and deploy AWS Lambda functions directly from within the IDE in my blogpost: camillovisini.com/… Hope this helps!
  • Marakai
    Marakai over 5 years
    As comments are ephemeral, I'll take the liberty and add your links to my answer.
  • Samuel Prevost
    Samuel Prevost about 5 years
    As of February 2019 AWS Toolking (SAM) works with python 3.7 . Just be sure to first install brew install docker, then brew cask install docker and finally brew tap aws/tap & brew install aws-sam-cli
  • Bala
    Bala almost 4 years
    Currently using pycharm I created a sample project using AWS serverless template. When I run, I get "SAM build command failed" error
  • Marakai
    Marakai almost 4 years
    @BalakumarEzhilmaran have you told PyCharm where you SAM executable is? It may not be able to find it for some reason (you DID install aws-sam-cli where PyCharm can find it right?)
  • alexeydemin
    alexeydemin almost 4 years
    @CamilloVisini It does work, but extremely slow. It takes 10 seconds "Running SAM Build" and the 22 additional seconds to show the hello-world output on Ubuntu.