Testing and Deployment
A Lambda function processes Amazon SQS messages, and a developer wants to test its handling of multiple messages in one invocation. How should the developer structure the saved test event?
Show the answer
Correct answerC. Use a Records array with each message body represented as a string.
AWhy not this: A body object containing messages does not match the SQS event structure.
BWhy not this: SQS delivers an event object containing Records, not a top-level array of message bodies.
CWhy this is right: The Records array represents the batch, and each record contains a string-valued body.
DWhy not this: SQS places messages in Records rather than properties keyed by message identifier.
An SQS event contains a Records array, with each record's body represented as a string, even when that string contains JSON. A top-level array of message bodies does not match the event structure Lambda receives from SQS.