aws / aws-toolkit-vscode

Amazon Q, CodeCatalyst, Local Lambda debug, SAM/CFN syntax, ECS Terminal, AWS resources
https://marketplace.visualstudio.com/items?itemName=AmazonWebServices.amazon-q-vscode
Apache License 2.0
1.48k stars 413 forks source link

No module named 'lambda_function' #4562

Open rejji opened 6 months ago

rejji commented 6 months ago

Describe the bug lambda_function is not locatable when executed from aws lambda console when locally things work fine.

To Reproduce

Expected behavior Lambda should execute without giving this error: No module named 'lambda_function'

Screenshots

Attaching

Screenshot 2024-03-20 at 10 05 58 AM Screenshot 2024-03-20 at 9 52 43 AM Screenshot 2024-03-20 at 9 53 21 AM Screenshot 2024-03-20 at 9 55 30 AM Screenshot 2024-03-20 at 7 37 11 AM

StripeWebhookProcessor.tgz: Use this to open vcode and upload to lambda

Toolkit Logs If applicable, attach toolkit logs by navigating to Extensions / AWS Toolkit / View Toolkit Logs: This navigation is not showing up. I have checked the folder and adding following files from the folder ~/Library/Application Support/Code/logs/20240320T084750 for whatever executed today (20Mar). If something else is reqd let me know.

.//window3/exthost/amazonwebservices.aws-toolkit-vscode/aws_toolkit_20240320T084758.log .//window2/exthost/amazonwebservices.aws-toolkit-vscode/aws_toolkit_20240320T084759.log .//window1/exthost/amazonwebservices.aws-toolkit-vscode/aws_toolkit_20240320T084757.log

Development System (please complete the following information):

Additional context Following are few things I want to rectify wrt the files template.yaml, samconfig.toml using cli or click buttons rather than manually editing the file. How to do these?

Thanks

awschristou commented 6 months ago

It looks like you are using the AWS Toolkit for VS Code, not the AWS Toolkit for Visual Studio. I will transfer this issue to the correct repo.

justinmk3 commented 6 months ago

HelloWorldFunction in your screenshots, maps to the name of the cloudformation "resource", it's unrelated to the hello_world folder name.

In the SAM template, Handler: lambda_function.lambda_handler means that Lambda will look for a python module (i.e. file) named lambda_function which contains a function named lambda_handler.

I renamed the folder/project to StripeWebhookProcessor from StripeInBackend via VisualStudio. How to ensure this renaming is taken care in config files.

Not possible currently.

Also, I had put in three event files under events/ folder. After right-click-and-upload, these are not even visible in the AWS Lambda console.

I believe the events/ folder is for sample payloads used by SAM CLI. The AWS Toolkit "Upload Lambda" doesn't do anything with that folder, currently.