Bird
0
0

How would you modify this Lambda handler to log the remaining execution time before returning the event?

hard📝 Application Q9 of 15
AWS - Lambda
How would you modify this Lambda handler to log the remaining execution time before returning the event?
def lambda_handler(event, context):
    return event
Adef lambda_handler(event, context): print(context.get_remaining_time()) return event
Bdef lambda_handler(event, context): print(context.remaining_time()) return event
Cdef lambda_handler(event, context): print(context.get_remaining_time_in_millis()) return event
Ddef lambda_handler(event, context): print(context.remaining_millis()) return event
Step-by-Step Solution
Solution:
  1. Step 1: Recall context method for remaining time

    The correct method to get remaining time in milliseconds is get_remaining_time_in_millis().
  2. Step 2: Verify correct usage in print statement

    def lambda_handler(event, context): print(context.get_remaining_time_in_millis()) return event correctly calls context.get_remaining_time_in_millis() and prints it before returning event.
  3. Final Answer:

    def lambda_handler(event, context): print(context.get_remaining_time_in_millis()) return event -> Option C
  4. Quick Check:

    Use get_remaining_time_in_millis() to log remaining time [OK]
Quick Trick: Use context.get_remaining_time_in_millis() to get time left [OK]
Common Mistakes:
  • Using incorrect method names
  • Calling methods without parentheses
  • Confusing remaining time units

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes