7

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.

petezurich
  • 9,280
  • 9
  • 43
  • 57
exan
  • 3,236
  • 5
  • 24
  • 38

2 Answers2

11

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.

Marakai
  • 1,163
  • 11
  • 26
  • Thanks, and here is the link from [AWS](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) with detailed discussion and documentation – exan Dec 10 '18 at 03:10
  • 3
    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: https://camillovisini.com/deploy-serverless-python-functions-aws-lambda-pycharm/ Hope this helps! – Camillo Dec 10 '18 at 19:45
  • 1
    As comments are ephemeral, I'll take the liberty and add your links to my answer. – Marakai Dec 11 '18 at 01:25
  • 2
    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` – Samuel Prevost Feb 21 '19 at 08:58
  • Currently using pycharm I created a sample project using AWS serverless template. When I run, I get "SAM build command failed" error – Bala May 04 '20 at 13:49
  • @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?) – Marakai May 05 '20 at 01:30
  • @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. – alexeydemin Jun 29 '20 at 21:18
3

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