Bird
0
0

A Lambda function using a layer fails with "ModuleNotFoundError" despite the layer being attached. What is a likely cause?

medium📝 Debug Q7 of 15
AWS - Lambda
A Lambda function using a layer fails with "ModuleNotFoundError" despite the layer being attached. What is a likely cause?
AThe function's timeout is exceeded
BThe function's memory size is too low
CThe layer version is deprecated
DThe layer's folder structure does not match the expected import path
Step-by-Step Solution
Solution:
  1. Step 1: Understand ModuleNotFoundError cause

    This error means Python cannot find the module in the import path.
  2. Step 2: Check layer folder structure

    If the layer's files are not in the correct folder (e.g., python/lib/python3.x/site-packages), imports fail.
  3. Final Answer:

    The layer's folder structure does not match the expected import path -> Option D
  4. Quick Check:

    ModuleNotFoundError = wrong layer folder structure [OK]
Quick Trick: Layer folder must match language import paths exactly [OK]
Common Mistakes:
MISTAKES
  • Blaming memory or timeout for import errors
  • Assuming deprecated version causes import failure
  • Ignoring folder structure requirements

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes