Fix AWS Lambda Layer Imports in VS Code
How to fix the Red Squiggle Nightmare.
Picture this: You’re building a serverless application with AWS Lambda layers. Your architecture is beautiful — shared code organised in layers, clean imports, everything modular and DRY. You deploy to AWS and it works flawlessly.
But back in your local environment, your IDE is having a complete meltdown. Red and Yellow squiggles are everywhere. IntelliSense is giving up. Pylint is throwing tantrums. VS Code treats your production-perfect imports like radioactive waste.

You’re living in developer hell. Every import shows as an error, autocomplete is gone, and you’ve lost all the IDE intelligence that makes you productive. Well, guess what? There’s a simple fix that takes 30 seconds.
The Problem: Your IDE Can’t See Lambda Layers
AWS Lambda layers work by mounting your layer code into the Lambda runtime at /opt/python. But your local IDE doesn’t know about this special Lambda magic — it only looks in standard Python paths. VS Code is searching in:
- Your current directory
- Site packages
- Standard Python paths
It has no clue that models lives in:
./lambdas/layers/common/python/models.py.
Or wherever yours is living.
The Fix: Tell VS Code Where to Look
Create .vscode directory in the root of your project with:
mkdir .vscodeEnter the directory and create a settings.json:
touch settings.jsonPaste in the following code:
{
"python.analysis.extraPaths": ["./path/to/your/lambda/layer"]
}Save, and look again at your code:

Commit your .vscode directory to source control to share the love with your fellow developers.
Why This Works
With this addition, VS Code now searches:
- Current directory
- Site packages
- Your lambda layer path ← The magic addition
This mirrors how AWS Lambda resolves imports at runtime, where layer content is available in the Python path. This fix is fast, simple, and has zero impact on the code you upload to AWS — the ultimate win-win-win.
That’s it! I hope this saved you the 15 minutes it took me to solve this small, but irritating problem. Happy Developing!