AWS Systems Architect Professional

Build an S3-to-Lambda Amazon Rekognition Image Analysis Pipeline – SAP-C02 Study Guide

Learn how to design an S3-triggered Lambda pipeline that analyzes images with Amazon Rekognition and stores results in DynamoDB, including IAM, resiliency, and exam traps.

AWS Systems Architect ProfessionalAWS Systems Architect ProfessionalUpdated Sep 1, 2026
Study options
WatchComing later
ListenComing later
ReadAvailable
ReviewComing later

Study guide

Technical reference and lesson notes

Purpose of This Lesson

This lesson demonstrates a simple event-driven image analysis workflow using Amazon S3, AWS Lambda, Amazon Rekognition, and Amazon DynamoDB.

When an image is uploaded to an S3 bucket:

  1. Amazon S3 emits an object-created event.
  2. The event invokes a Lambda function.
  3. Lambda passes the S3 object location to Amazon Rekognition.
  4. Rekognition identifies labels and returns confidence scores.
  5. Lambda stores the analysis results in DynamoDB.

Although the broader course topic may include video processing, this implementation focuses on still images. The same architectural principles apply to other media-processing workflows, but video analysis generally requires different Rekognition APIs and processing patterns.

Key Concepts

S3 as the media intake point

Amazon S3 provides durable, scalable storage for uploaded images. It is a natural entry point for event-driven processing because object creation can generate notifications for downstream services.

Important design considerations include:

  • Use a dedicated bucket or prefixes such as incoming/ and processed/.
  • Keep the bucket private and use IAM roles rather than public access.
  • Enable server-side encryption, preferably with an AWS KMS key when customer-controlled key management is required.
  • Consider S3 Versioning if objects may be overwritten or need recovery.
  • Avoid writing processed output back to the same triggering prefix unless the workflow prevents recursive invocations.

S3 event notifications and Lambda

An S3 object-created event contains metadata such as the bucket name and object key. Lambda uses this information to retrieve or analyze the object.

The event trigger should normally be restricted by:

  • Event type, such as ObjectCreated.
  • Object key prefix, such as incoming/.
  • Object suffix, such as .jpg or .png.

A broad trigger for every object-created event is convenient for a lab, but it can cause unnecessary invocations or recursive processing in production.

S3 notifications can target Lambda, Amazon SQS, Amazon SNS, or Amazon EventBridge. Direct S3-to-Lambda invocation is simple, while an SQS buffer is usually more resilient when processing may be slow, bursty, or subject to downstream throttling.

Lambda execution role

Lambda requires an execution role that grants permissions to the AWS APIs called by the function. A production role should follow least privilege. It may need permissions such as:

  • s3:GetObject for the specific source bucket and prefix.
  • Rekognition permissions required by the selected API, such as rekognition:DetectLabels.
  • dynamodb:PutItem for the specific results table.
  • CloudWatch Logs permissions, normally supplied by the basic Lambda execution policy.

Granting managed policies such as Amazon S3 read-only, Amazon Rekognition full access, or DynamoDB full access is acceptable for experimentation but is unnecessarily broad for a production solution.

Amazon Rekognition label detection

Amazon Rekognition can analyze images and return detected labels, categories, and confidence values. A result can include multiple labels for one image—for example, a computer image might produce labels related to electronics, a monitor, a table, or other visible objects.

Confidence scores indicate how strongly Rekognition associates a label with the image. They should not automatically be treated as absolute truth. Applications may apply a minimum confidence threshold, such as accepting only labels above a business-defined percentage.

The selected API determines what the application can detect. Label detection is different from face comparison, facial analysis, text detection, moderation detection, and custom-label workflows.

DynamoDB for result storage

DynamoDB provides a low-latency, schemaless data store for analysis results. A simple table can use the image name or object key as its partition key.

Using only an image name is convenient but may not be globally unique. A stronger key design uses the complete S3 object key, a generated object ID, or a composite identifier that includes the bucket, key, and version ID.

A result item might contain:

  • Image identifier or S3 object key.
  • Bucket name and object version ID.
  • Detected labels.
  • Confidence scores.
  • Processing timestamp.
  • Processing status or error details.
  • Rekognition API version or application version.

DynamoDB item size limits, request capacity, and access patterns should be considered if storing large or numerous labels. Large result payloads may be better stored in S3, with DynamoDB containing metadata and an S3 reference.

Synchronous versus decoupled processing

A simple Lambda function can invoke Rekognition and then write the result to DynamoDB within the same invocation. This is easy to understand, but it couples intake, analysis, and persistence to one execution.

A more resilient design separates the stages:

S3 upload
   -> SQS queue
   -> analysis Lambda
   -> Amazon Rekognition
   -> results queue or EventBridge
   -> persistence Lambda
   -> DynamoDB

Benefits of decoupling include:

  • Queue-based buffering during upload spikes.
  • Independent retries for failed stages.
  • Shorter Lambda execution times.
  • Better control over Rekognition API rate limits.
  • Easier scaling and operational isolation.

For workflows that require immediate results and have low volume, direct S3-to-Lambda may be sufficient.

Architecture Decision Guide

RequirementRecommended approachReason
Small, low-volume image workflowS3 event notification to LambdaSimple and inexpensive to operate
Bursty uploads or slow downstream processingS3 to SQS to LambdaBuffers work and supports controlled consumption
Multiple consumers need the upload eventS3 to EventBridge or SNSDistributes events to several targets
Store small queryable analysis resultsDynamoDBLow-latency key-value access
Store large result documentsS3 plus DynamoDB metadataAvoids putting oversized payloads in DynamoDB
Restrict processing to images in one directoryS3 notification with prefix and suffix filtersReduces unwanted invocations
Protect against duplicate processingIdempotency key based on bucket, key, and versionS3 events and retries can result in repeated delivery
Long-running or multi-step workflowStep Functions with Lambda tasksProvides orchestration, retries, and state tracking
Highly controlled permissionsCustomer-managed IAM policyFollows least privilege and improves auditability

Exam-Relevant Takeaways

  • S3 object events can invoke Lambda for event-driven processing.
  • Lambda must use an execution role with permissions for every AWS API it calls.
  • The S3 bucket does not automatically grant Lambda access to the object; s3:GetObject authorization is still required.
  • Rekognition returns labels and confidence values, and one image can produce multiple labels.
  • DynamoDB is appropriate for metadata and queryable results, not necessarily large binary or document payloads.
  • Direct service integration is simple, but SQS improves buffering, retry handling, and workload isolation.
  • Lambda timeout must be long enough for all work performed during one invocation, but increasing the timeout is not a substitute for proper decoupling.
  • Event-driven systems should be designed for retries and duplicate delivery. Result writes should be idempotent.
  • Use resource-specific IAM permissions instead of broad managed policies in production.
  • S3 notification filters can reduce unnecessary Lambda invocations and help prevent processing loops.

Common Exam Traps

Assuming S3 events are exactly once

Do not design as if every event is delivered exactly once. Processing can be retried, and duplicate results may occur. Use an idempotency strategy and conditional DynamoDB writes where appropriate.

Giving Lambda full access to every service

A solution that attaches broad full-access policies may work but violates least privilege. Restrict actions and resources to the required bucket, prefixes, table, and Rekognition operations.

Ignoring recursive S3 triggers

If Lambda writes an output object into the same bucket and the notification covers all object-created events, the function may invoke itself repeatedly. Use separate buckets, dedicated prefixes, or suffix filters.

Treating the image name as a guaranteed unique key

Two uploads can have the same filename, especially across folders or users. Store the full S3 key and, when versioning is enabled, the object version ID or another unique identifier.

Using Lambda for work that exceeds its execution model

A single synchronous invocation is not always suitable for long-running, high-volume, or highly variable workloads. Use SQS, Step Functions, or another orchestration pattern when the workflow needs buffering and controlled retries.

Assuming a confidence score is a business decision

Rekognition’s confidence value is an analytical signal. The application must define thresholds and handling for uncertain or conflicting results.

Confusing image and video analysis

Still-image label detection and video analysis are not interchangeable. Video workflows may involve stored video, asynchronous analysis, job identifiers, SNS notifications, and result pagination.

Real-World Engineer Notes

  • Enable CloudWatch Logs and metrics for invocation errors, duration, throttles, and failed writes.
  • Use structured logs containing the S3 key, object version, request ID, and processing status.
  • Validate the event source and object metadata before calling Rekognition.
  • Avoid trusting user-supplied filenames as database keys without normalization or collision handling.
  • Configure dead-letter handling or an SQS retry path for records that repeatedly fail.
  • Consider reserved or provisioned concurrency when controlling downstream Rekognition request volume is important.
  • Store the original object and analysis results under separate prefixes or buckets.
  • Use S3 lifecycle policies to manage temporary uploads and old versions.
  • Encrypt S3 and DynamoDB data at rest and use TLS for service calls.
  • If the workflow is multi-step, Step Functions can make retry policies and state transitions more visible than embedding everything in one Lambda function.
  • For sensitive imagery, apply appropriate access controls, logging, retention, and data-governance policies.

Quick Reference Summary

S3 object upload
    -> ObjectCreated event
    -> Lambda execution role
    -> Amazon Rekognition image API
    -> Label and confidence results
    -> DynamoDB item

Key implementation checklist:

  • Create a private S3 bucket.
  • Define an S3 object-created trigger with appropriate filters.
  • Configure Lambda with a suitable runtime and timeout.
  • Grant least-privilege permissions for S3, Rekognition, DynamoDB, and CloudWatch Logs.
  • Use a unique, idempotent result key.
  • Add queueing or orchestration when processing is slow, bursty, or failure-prone.
  • Monitor failures and retain enough metadata to retry or investigate processing.

Flashcards

1. What AWS service can invoke Lambda when an object is uploaded to S3?

An S3 event notification, typically for an ObjectCreated event.

2. What role authorizes a Lambda function to call AWS services?

The Lambda execution role, which Lambda assumes during execution.

3. What permission does Lambda commonly need to analyze an object stored in S3?

s3:GetObject on the required bucket and object path.

4. What does Amazon Rekognition return for label detection?

Detected labels and associated confidence values, potentially with multiple labels per image.

5. Why is DynamoDB suitable for Rekognition results?

It provides low-latency access to structured, queryable metadata keyed by an image identifier.

6. Why can an image filename be a poor DynamoDB partition key?

Filenames may collide across users, folders, or uploads and may not uniquely identify an object version.

7. What service can buffer S3 events before Lambda processes them?

Amazon SQS.

8. How can an S3-to-Lambda processing loop be prevented?

Use separate buckets, restrict notifications to an input prefix, or filter by object suffix.

9. Why should image-processing workflows be idempotent?

Events can be retried or delivered more than once, so repeated processing should not corrupt or duplicate results.

10. What is the main weakness of doing Rekognition and DynamoDB writes in one Lambda invocation?

The stages are tightly coupled, so failures, latency, and scaling behavior affect the whole invocation.

11. When might Step Functions be preferable to one Lambda function?

When processing requires multiple steps, explicit state tracking, controlled retries, or long-running orchestration.

12. Should a Rekognition confidence score automatically determine whether an image is accepted?

No. The application should define an appropriate confidence threshold and business rule.

Practice Questions

Question 1

A company receives thousands of image uploads in short bursts. Each image must be analyzed with Amazon Rekognition, but Rekognition request throttling occasionally causes Lambda failures. The company wants to absorb bursts and retry failed processing without losing uploads. Which architecture is best?

A. Invoke Rekognition directly from the S3 notification and increase the Lambda timeout.
B. Configure S3 to send events to an SQS queue, then invoke Lambda from the queue.
C. Upload images directly to DynamoDB before invoking Rekognition.
D. Use an SNS topic with no retry or dead-letter configuration.

Correct answer: B

SQS provides durable buffering, controlled Lambda consumption, and retry behavior. Increasing the timeout does not address burst management or downstream throttling.

Question 2

A Lambda function analyzes an S3 image and writes the result to DynamoDB. The function’s execution role currently has Amazon S3 read-only, Amazon Rekognition full access, and DynamoDB full access managed policies. A security review requires least privilege. Which change best meets the requirement?

A. Remove the execution role and place AWS access keys in the Lambda environment variables.
B. Keep all managed policies because Lambda requires broad permissions.
C. Replace them with a policy allowing only the required Rekognition action, s3:GetObject for the input prefix, and dynamodb:PutItem on the results table.
D. Grant the Lambda function administrator access so future API changes do not cause failures.

Correct answer: C

The execution role should allow only the actions and resources required by the function. Static credentials and administrative access are inappropriate solutions.

Question 3

A processing Lambda writes thumbnails to the same S3 bucket that triggers it. The S3 notification listens for all object-created events. The function begins invoking repeatedly. What is the most direct fix?

A. Increase the Lambda memory allocation.
B. Disable S3 Versioning.
C. Configure the notification to process only the input prefix or use a separate output bucket.
D. Increase the DynamoDB read capacity.

Correct answer: C

Filtering the event to the input location or separating input and output storage prevents the function’s own output from triggering another invocation.

Question 4

An application stores Rekognition results in DynamoDB using only the uploaded filename as the partition key. Different customers can upload files with the same name, and the application must retain every analysis result. What should the architect recommend?

A. Use a unique identifier such as the full S3 key plus object version ID or a generated upload ID.
B. Use the confidence score as the partition key.
C. Store all results in one DynamoDB item with the filename as a nested attribute.
D. Disable retries on the Lambda function.

Correct answer: A

A globally unique and stable identifier prevents overwrites and supports idempotency. The full key and version information can distinguish otherwise identical filenames.

Question 5

A workflow performs image validation, Rekognition analysis, result persistence, and notification. Each stage has a different retry policy, and operators need to determine which stage failed. Which AWS service is most appropriate for coordinating the workflow?

A. AWS Step Functions
B. Amazon Route 53
C. Amazon CloudFront
D. AWS CodeArtifact

Correct answer: A

Step Functions provides visible workflow state, service integrations, per-step retry and catch behavior, and orchestration across multiple processing stages.