Bird
0
0

Given this Python Lambda function code snippet using a layer for shared utilities:

medium📝 Predict Output Q13 of 15
AWS - Lambda
Given this Python Lambda function code snippet using a layer for shared utilities:
import shared_utils

def lambda_handler(event, context):
    return shared_utils.process(event)

What will happen if the Lambda function is invoked but the layer is not attached?
AThe function will timeout waiting for the layer
BThe function will run successfully without errors
CThe function will return None silently
DThe function will raise a ModuleNotFoundError for 'shared_utils'
Step-by-Step Solution
Solution:
  1. Step 1: Understand import behavior without layer

    If the layer providing shared_utils is missing, Python cannot find the module and raises an error.
  2. Step 2: Identify the error type

    Python raises ModuleNotFoundError when an import fails.
  3. Final Answer:

    The function will raise a ModuleNotFoundError for 'shared_utils' -> Option D
  4. Quick Check:

    Missing layer = ModuleNotFoundError [OK]
Quick Trick: Missing layer means missing module, causing import error [OK]
Common Mistakes:
  • Assuming function runs without the layer
  • Expecting silent failure or None return
  • Thinking function times out due to missing layer

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes