Cert EspressoLearn. Practise. Find your flow.

A LITTLE FOCUS.
A BIG NEXT STEP.

Your pace. Your space.
AWS · DVA-C03

Lambda events, errors, and integrations

DVA-C03 · Lesson 7 of 24 · 55:44

YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗

Learning with these videos? Subscribe for new courses and exam-style questions.

In this lesson

Prepare for the DVA-C03 exam (AWS Certified Developer – Associate). In this lesson: synchronous, asynchronous, and event source mapping invocations, retries, destinations, dead-letter queues, errors with SQS and streams, partial batch responses, event filtering, API Gateway, function URLs, and DynamoDB Streams. Includes three original practice questions.

Study notes

The text of this lesson, to read at your own pace. Information as of November 2026.

Where the events come from

At AnyCompany Tickets, Lambda functions receive events from everywhere: requests from the API, files uploaded to S3, messages from the order queue, and changes to the DynamoDB tables. Each source invokes the function in its own way, and handles failures in its own way. This lesson covers the three ways that Lambda is invoked, retries, destinations and dead-letter queues, and the integrations with API Gateway, queues, and streams.

Three ways to invoke

With a synchronous invocation, the caller waits for the response, like API Gateway or an SDK call, and the caller handles any retry. With an asynchronous invocation, a service like S3, SNS, or EventBridge hands the event to Lambda, which queues it, answers at once, and retries on its own. With an event source mapping, Lambda itself polls a queue or a stream, like SQS, Kinesis, or DynamoDB Streams, and invokes the function with batches of records. So the question is always: who retries, and where do failed events go?

Retries and destinations

For an asynchronous invocation that fails, Lambda retries twice by default, and keeps an event for up to six hours. You can lower both settings, down to zero retries, to avoid repeating work that should not run twice. Destinations then send a record of each invocation to another service: on success or on failure, to an SQS queue, an SNS topic, another function, or an EventBridge event bus. A dead-letter queue, an SQS queue or an SNS topic, keeps only the failed events, with less detail. For new designs, an on-failure destination is usually the better choice, since it keeps the error and the response too.

Queues and streams

With an SQS queue, Lambda deletes the messages of a batch when the function succeeds. When it fails, the messages come back after the visibility timeout, so set that timeout to at least six times the function's timeout. A redrive policy on the queue moves a message to its dead-letter queue after a number of receives, at least five, as AWS recommends. With partial batch responses, the function reports only the failed message IDs, so the others are not processed again. For Kinesis and DynamoDB Streams, a failed batch blocks its shard, so limit the retries or the record age, split failed batches, and send the details to an on-failure destination.

Filters and integrations

An event source mapping can filter the records, so the function only runs for the events that matter, like orders with the status paid. API Gateway invokes a function synchronously, with a proxy integration that passes the whole request, and expects a response with a status code, headers, and a body. A function URL gives a single function its own HTTPS endpoint, without the features of API Gateway, like usage plans. And DynamoDB Streams lets a function react to each change in a table, for example to send a confirmation email after a new order.

Choosing the integration

Each need maps to an integration. A REST call that waits for an answer goes through API Gateway, or a function URL for a simple endpoint. A file in S3, or an event on a bus, invokes the function asynchronously, with destinations for failures. Work that must absorb spikes goes through an SQS queue with an event source mapping, and ordered changes come from a stream.

Recap

Let's recap. Synchronous callers handle their own retries, asynchronous events are retried by Lambda, and event source mappings poll queues and streams. Asynchronous failures go to an on-failure destination, which keeps the error, or to a dead-letter queue. With SQS, set the visibility timeout to six times the function's timeout, add a redrive policy, and report partial batch failures. With streams, a bad record blocks its shard, so limit retries and record age, and split batches. And filters, API Gateway, function URLs, and DynamoDB Streams connect functions to the rest of the app.

Quick checks for this lesson

The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.

  1. S3 invokes a function for each uploaded seating plan. When the function fails after its retries, the team wants the failed event, along with the error details, sent to an SQS queue for review. What should the developer configure?

    • An on-failure destination for the function
    • A dead-letter queue on the function itself
    • More retry attempts for asynchronous events
    • A redrive policy with a maximum receive count
    Show the answer

    An on-failure destination for the function

    An on-failure destination receives the event with the details of the error and the response. “A dead-letter queue on the function itself” would only keep the original event, without the details that the team wants. “More retry attempts for asynchronous events” would retry the same failing work more often, and still lose the event at the end. And “A redrive policy with a maximum receive count” would apply to a polled queue, while S3 invokes the function asynchronously.

  2. A function reads batches of ten messages from an SQS queue. When one message in a batch is malformed, all ten are processed again, and some customers receive two emails. What should the developer do?

    • Add a dead-letter queue with a redrive policy
    • Lower the visibility timeout of the queue
    • Set the batch size of the mapping to one
    • Report the failed IDs in a partial batch response
    Show the answer

    Report the failed IDs in a partial batch response

    With partial batch responses, the function returns only the failed message IDs, and the others are deleted. “Add a dead-letter queue with a redrive policy” would only send the bad message to the dead-letter queue later, after more repeats. “Lower the visibility timeout of the queue” would make each repeat come back sooner, without stopping it. And “Set the batch size of the mapping to one” would slow every message down, and keep the same repeats.

  3. A function reads every message from the order queue, but it only acts on orders with the status paid, and returns at once for the others. The team pays for millions of useless invocations, and the producer must not change. What should the developer configure?

    • A status check at the top of the handler
    • Filter criteria on the event source mapping
    • A separate queue for the paid orders
    • A batch size of one on the mapping
    Show the answer

    Filter criteria on the event source mapping

    Filter criteria on the event source mapping drop the other messages before Lambda invokes the function. “A status check at the top of the handler” would keep the same check in the code, after each invocation has already started. “A separate queue for the paid orders” would ask the producer to change, which the team rules out. And “A batch size of one on the mapping” would invoke the function for each message on its own, more often than before.