How to setup PyCharm to develop AWS Lambda function on local machine?
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
exan
Updated on June 15, 2022Comments
-
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 over 5 yearsThanks, and here is the link from AWS with detailed discussion and documentation
-
Camillo over 5 yearsI'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 over 5 yearsAs comments are ephemeral, I'll take the liberty and add your links to my answer.
-
Samuel Prevost about 5 yearsAs of February 2019 AWS Toolking (SAM) works with python 3.7 . Just be sure to first install
brew install docker
, thenbrew cask install docker
and finallybrew tap aws/tap
&brew install aws-sam-cli
-
Bala almost 4 yearsCurrently using pycharm I created a sample project using AWS serverless template. When I run, I get "SAM build command failed" error
-
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 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.