S3 Event Notifications: Lambda, SNS, and SQS Quiz Quiz

Explore your understanding of configuring S3 event notifications with Lambda functions, SNS topics, and SQS queues. This quiz covers key concepts, event types, supported destinations, and typical scenarios for integrating S3 event triggers with messaging and compute services.

  1. S3 Event Destinations

    Which of the following services can directly receive event notifications from S3 for object creation events?

    1. IAM roles
    2. CloudFront distributions
    3. Auto Scaling groups
    4. Lambda functions

    Explanation: S3 can directly send event notifications to Lambda functions, enabling users to process files automatically as they are uploaded. Auto Scaling groups and CloudFront distributions are not valid direct notification targets for S3 events. IAM roles are used for permissions but cannot themselves receive S3 event notifications.

  2. Supported Event Types

    If you want to trigger a notification every time a file is permanently deleted from a bucket, which S3 event type should you use?

    1. s3:ObjectRemoved:Delete
    2. s3:ObjectAccessed:Get
    3. s3:ObjectCreated:Put
    4. s3:ObjectRestore:Post

    Explanation: The event type 's3:ObjectRemoved:Delete' captures permanent deletions of objects from the bucket. 's3:ObjectCreated:Put' relates to object uploads, while 's3:ObjectRestore:Post' is triggered during restoration from archives. 's3:ObjectAccessed:Get' is not a supported S3 event type.

  3. SNS Integration Scenario

    You want to notify multiple subscribers whenever an object is added to your S3 bucket. Which destination allows easy fan-out to multiple endpoints?

    1. IAM policy
    2. EC2 instance
    3. SNS topic
    4. Lambda function

    Explanation: SNS topics are designed to fan out messages to multiple endpoints, such as email, HTTP, or other queues. A Lambda function is best for processing individual events but does not provide built-in fan-out to multiple subscribers. IAM policies control permissions but do not receive notifications, and EC2 instances cannot directly receive S3 event notifications.

  4. SQS Queue Behavior

    When using an SQS queue as a destination for S3 events, what is a key benefit for processing notifications?

    1. Automatic object replication
    2. Real-time analytics
    3. Direct file transfers
    4. Decoupling producers and consumers

    Explanation: An SQS queue helps decouple the source of events (S3) from the event consumers by storing messages until they are processed. Automatic object replication is not a built-in feature of SQS queues. Real-time analytics and direct file transfers are unrelated to the queueing functionality provided by SQS.

  5. Lambda Trigger Filtering

    How can you ensure a Lambda function is only triggered by S3 events for files with .jpg extensions?

    1. Using event notification prefix and suffix filters
    2. Setting a retention policy on S3
    3. Changing the bucket's region
    4. Writing a custom IAM policy

    Explanation: Event notification filters, such as suffix filters for '.jpg', allow S3 to trigger notifications only when object keys match specific patterns. IAM policies control who can take actions but do not filter events. Retention policies manage object lifecycles, and the bucket region is unrelated to event filtering.

  6. Event Delivery Guarantee

    Which statement best describes the reliability of S3 event notification delivery to SQS queues and SNS topics?

    1. S3 does not support notifications to SQS or SNS
    2. S3 guarantees exactly-once delivery to all destinations
    3. S3 guarantees at-least-once delivery to SQS and SNS
    4. S3 sends notifications only when objects are large

    Explanation: S3 event notifications to SQS and SNS are delivered at least once, which means messages might be delivered more than one time. S3 does not guarantee exactly-once delivery, and notification delivery is not dependent on object size. S3 does support notifications to both SQS and SNS.

  7. Enabling Notifications

    Where do you configure S3 event notifications to trigger an SNS topic when a new object is uploaded?

    1. In the object's metadata
    2. In the IAM role description
    3. Directly inside SQS queue settings
    4. In the S3 bucket's properties

    Explanation: S3 event notifications are configured in the properties section of the S3 bucket settings. SQS queue settings and IAM role descriptions are unrelated to configuring S3 event notifications. Object metadata does not contain notification configuration options.

  8. Limitations of Destinations

    Which of the following cannot directly receive S3 event notifications as a destination?

    1. Lambda function
    2. SQS queue
    3. SNS topic
    4. Database table

    Explanation: Database tables are not valid direct destinations for S3 event notifications. In contrast, Lambda functions, SQS queues, and SNS topics are supported destinations. Database tables may receive event data indirectly if processed by an application, but cannot be selected directly in the S3 configuration.

  9. Multiple Destinations

    Is it possible to send the same S3 event notification to both a Lambda function and an SQS queue?

    1. No, S3 only supports one destination per event type
    2. Yes, by creating multiple notification configurations
    3. Only if you use third-party tools
    4. Yes, but only for delete events

    Explanation: S3 allows multiple notification configurations per bucket, so the same event can trigger different destinations like Lambda and SQS. The claim that only one destination is supported is incorrect. Third-party tools are unnecessary for this feature, and it is not limited specifically to delete events.

  10. Notification Permissions

    What permission must be granted for S3 to successfully invoke a Lambda function on an event?

    1. GrantAll permission for Lambda
    2. InvokeFunction permission for the bucket
    3. ReadObject permission on all objects
    4. PutBucketNotification permission

    Explanation: S3 needs permission to invoke the Lambda function, typically requiring the 'InvokeFunction' action for the bucket. 'ReadObject' allows reading of objects, but does not allow Lambda invocation. 'PutBucketNotification' allows editing notification configurations rather than executing them. 'GrantAll' is not a valid permission action.