Kartik Kodag
Kartik Kodag

Reputation: 83

Cant run Local python lambda function using AWS toolkit

I have Intellij and AWS toolkit plugin installed in it. I want to run simple python lambda from project which has a structure as below.

Project_name

Now I want to run the lambda function lcoally so I configure the AWS toolkit run-configuration as below. But it gives me error saying "cannot locate the handler" or says "Error: Lambda handler validation is in progress"

Run configuration for lambda debugging locally

Could someone who have used the AWS toolkit to run the config locally help me here, what am I missing.

I tried changing the handler name to handler.get_handler or src.handler.get_handler OR get_handler. But cant get it working.

Other details- I am using global python 3.11 as the interpreter here in the project and not venv.

Upvotes: 0

Views: 66

Answers (1)

0xn0b174
0xn0b174

Reputation: 1022

considering you have insalled boto3 and requests package installed globally as you are trying to use global python not venv

change you Handler value from :

handler.get_handler

to

src/handler.get_handler

as your handler is inside the src directory, you can run you lambda locally.

I am using global python 3.12 but i created venv using following python command and activating it:

python -m venv venv

source venv/bin/activate

and installed boto3 and requests from requirements.txt file in root of the project using following command:

pip install -r requiremnts.txt

and set the Handler value as : src/handler.get_handler

Input:

{
  "test": "data"
}

i colud run the lambda locally and get following output: enter image description here

note: make sure to try with both architectue x86_64 and arm64, x86_64 worked for me. kudos

Upvotes: 0

Related Questions