AWS Certified Developer – Associate — Question 280
A website allows users to upload photos to Amazon S3. An S3 event invokes an AWS Lambda function that uses the Amazon Rekognition DetectLabels operation to detect real-world objects within a photo. The website needs to store this data in a search index to allow users to quickly locate all photos associated with a label.
Which solution will meet these requirements?
Answer options
- A. Store username and label values as S3 object tags. Retrieve and index the objects based on the tag by calling the describe-tags API with the username and label value.
- B. Store username and label values as S3 object metadata keys. Include the "x-amz-meta-" prefix for each key. Search by metadata to find all the objects that share the username and label value.
- C. Insert an item for each S3 key, label, and user combination into an Amazon DynamoDB table. Create a global secondary index with the username as the partition key and the label as the sort key. Call the QueryItem API on the index to find all the objects that share the username and label value
- D. Insert an item for each S3 key, label, and user combination into an Amazon DynamoDB global secondary index. Define the username as the partition key. Define the label as the sort key. Call the QueryItem API on the index to find all the objects that share the username and label value.
Correct answer: C
Explanation
Amazon DynamoDB is designed for fast, single-digit millisecond latency queries, making it ideal for indexing photo metadata. To query by username and label, items must be written to a base DynamoDB table and projected to a global secondary index (GSI) configured with the username as the partition key and the label as the sort key. Options A and B are incorrect because S3 object tags and metadata cannot be queried efficiently like a database index, and Option D is incorrect because you cannot write directly to a GSI without writing to the base table first.