Bird
0
0

What is wrong with this AWS Lambda handler function in Python?

medium📝 Debug Q14 of 15
AWS - Lambda
What is wrong with this AWS Lambda handler function in Python?
def handler(event):
    return 'Done'
AMissing the required <code>context</code> parameter
BReturn value must be a dictionary
CFunction name must be <code>lambda_handler</code>
DNo error, this is valid
Step-by-Step Solution
Solution:
  1. Step 1: Check function parameters

    AWS Lambda handler functions must accept two parameters: event and context. This function only has event.
  2. Step 2: Validate other options

    Return type can vary by trigger, so returning a string is allowed. Function name can be configured, so handler is acceptable. Hence, only missing context is an error.
  3. Final Answer:

    Missing the required context parameter -> Option A
  4. Quick Check:

    Lambda handler needs event and context parameters [OK]
Quick Trick: Always include event and context parameters [OK]
Common Mistakes:
MISTAKES
  • Omitting context parameter
  • Thinking return must be dict always
  • Assuming fixed function name

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes