Data Operations and Support · Topic 1 of 6
Automating Data Processing
Automate data processing on AWS with Lambda event source mappings, EventBridge schedules, Glue triggers, the Redshift Data API and safe retries.
- 5 min
- Event source mappings poll Kinesis, DynamoDB Streams, SQS and MSK and invoke Lambda with batches.
- Use bisect on error, retry limits and an on failure destination to deal with poison records.
- Partial batch responses stop one bad SQS message from retrying the entire batch.
What it is
Automation removes manual steps from data processing. A pipeline should start on a schedule or on an event, retry on its own after a transient failure, and tell people only when it needs them.
This page looks at the day to day tooling: event source mappings, schedules, service APIs and the settings that make runs repeatable.
How it works
Lambda event source mappings
An event source mapping lets Lambda poll a source and invoke your function with batches. It supports Kinesis Data Streams, DynamoDB Streams, SQS and Amazon MSK among others. The mapping controls the batch size, a batching window and what to do with failed batches.
| Setting | Effect |
|---|---|
| Batch size and window | Collect more records per invocation, which lowers cost and call rate |
| Parallelization factor | Process more than one batch per shard at the same time (stream sources) |
| Bisect batch on error | Split a failing batch to find the bad record |
| Maximum retry attempts and record age | Stop retrying poison records after a limit |
| On failure destination | Send details about failed records to SQS or SNS |
For SQS, Lambda scales with queue depth, and a dead letter queue holds messages that fail too often. Use a partial batch response so that one bad record does not force the whole batch to retry.
Schedules and events
Amazon EventBridge rules and EventBridge Scheduler run jobs at fixed times or when an event matches a pattern. An S3 event can start a Lambda function when an object arrives, either directly or through EventBridge or SQS.
aws events put-rule --name nightly-etl --schedule-expression "cron(0 2 * * ? *)"
aws events put-targets --rule nightly-etl \
--targets "Id"="1","Arn"="arn:aws:lambda:us-east-1:123456789012:function:start-etl"
EventBridge cron expressions use six fields and run in UTC for rules. Remember that Lambda also needs a resource policy that lets EventBridge invoke it, which the console adds for you.
Calling services from automation
Most data services have APIs that a function or workflow can call.
| Task | Call |
|---|---|
| Start a Glue job | StartJobRun (Step Functions: glue:startJobRun.sync) |
| Run an Athena query | StartQueryExecution, then check status |
| Run Redshift SQL | Redshift Data API ExecuteStatement |
| Add an EMR step | AddJobFlowSteps |
| Refresh a QuickSight dataset | CreateIngestion |
The Redshift Data API is asynchronous. A function submits a statement, receives an ID and checks the result later, so it does not hold a database connection open. Redshift also supports scheduled queries from the query editor, and stored procedures run repeatable SQL logic inside the warehouse.
Consuming and maintaining data APIs
A client or workflow that calls a data API through API Gateway authenticates with IAM, a Cognito token or an API key tied to a usage plan. It should retry throttled calls (HTTP 429) with exponential backoff.
To release changes safely, publish each version to a stage, such as dev and prod, or put a version in the path, such as /v1. Keep the old version running until clients have moved.
Monitor the API with CloudWatch metrics, including request count, 4XX and 5XX errors, latency and cache hits and misses. Turn on access logging for the stage to record who called what. Alarm on error rate and latency, and use CloudTrail for changes to the API itself.
Glue and Athena automation
Glue triggers can start jobs on a schedule, on demand, or when other jobs and crawlers succeed. Glue jobs take parameters, so one script can process a different date each run. Athena queries can be scheduled through EventBridge and Step Functions, and CTAS or INSERT INTO statements write results back to S3.
Amazon MWAA covers larger, dependency heavy schedules with sensors and backfills, while Step Functions covers mixed service workflows. The earlier chapter compares them.
Making automation safe
Automated runs are only helpful if they are repeatable and observable.
- Idempotent writes: a re run overwrites a partition or merges on a key.
- Retries with backoff: handle throttling and short outages.
- Concurrency limits: protect databases and APIs from bursts.
- Parameters, not hardcoded values: the same code works in test and production.
- Alerts on failure: SNS or EventBridge notify the team.
- Least privilege roles: each function or job gets only the permissions it needs.
Batch API calls and bulk work
Some APIs accept many items per call, such as PutRecords for Kinesis, BatchWriteItem for DynamoDB and SendMessageBatch for SQS. Batching reduces call count and cost, but you must check the response for failed items, because a batch call can succeed overall while some records fail.
What to remember for the exam
- Event source mappings poll Kinesis, DynamoDB Streams, SQS and MSK and invoke Lambda with batches.
- Use bisect on error, retry limits and an on failure destination to deal with poison records.
- Partial batch responses stop one bad SQS message from retrying the entire batch.
- EventBridge schedules use cron or rate expressions. Rules match event patterns.
- The Redshift Data API runs SQL asynchronously without managing connections.
- Glue triggers chain jobs and crawlers, and job parameters make scripts reusable.
- Batch API calls can partially fail, so inspect the response.
- Automation needs idempotent writes, retries and alerts.
When a question says Lambda cannot keep a database connection open for a long statement, the Redshift Data API is the intended answer.
Common mistakes
Ignoring partial failures. PutRecords and BatchWriteItem return failed items that you must retry.
Retrying forever. A poison record can block a shard when retries are unlimited, so cap attempts and age.
Hardcoding dates. A pipeline that cannot take a date parameter is hard to backfill.
Running automation as an admin. Broad roles turn small bugs into large incidents.
A Kinesis or DynamoDB Streams consumer that keeps failing on one record can stall that shard until the record expires, so configure limits and a failure destination.
Check yourself
How can Lambda process a Kinesis stream without custom polling code?
Create an event source mapping that polls the stream and invokes the function with batches.
What stops one bad SQS message from retrying a whole batch?
A partial batch response that reports only the failed message IDs.
Which API lets Lambda run Redshift SQL without holding a connection?
The Redshift Data API.
Topic 1 of 6 in Data Operations and Support
Test yourself on Data Operations and Support
The full AWS DEA-C01 question bank has 845 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by AWS. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.