DVA-C02 exam dumps

DVA-C02 practice question 70 of 399

AWS Certified Developer - Associate. Associate level, Amazon Web Services. Free question with the correct answer and a full explanation.

DVA-C02 Question 70

Select 2

You are developing a serverless application on AWS that processes images uploaded to an S3 bucket. The application should trigger a Lambda function whenever a new image is uploaded to the bucket. The processing should only occur for image files (e.g., .jpg, .png) and should not trigger for other file types. How can you achieve this?

  1. A

    Set up an S3 Event Notification to trigger the Lambda function and use a Lambda function filter to process only image files.

  2. B

    Use an S3 Event Notification with a prefix and suffix filter to only trigger the Lambda function for files ending in '.jpg' or '.png'.

  3. C

    Configure the S3 bucket policy to allow Lambda invocation only for image file uploads.

  4. D

    Add a filter to the S3 Event Notification configuration for specific file extensions such as '.jpg' and '.png'.

  5. E

    Use an Amazon SQS queue between S3 and Lambda, and configure the queue to filter image files.

Show answer and explanation

Correct answers: B, D

Explanation

To trigger a Lambda function only for specific file types, you can use S3 Event Notifications with suffix filters. These filters can check the file extension (e.g., '.jpg', '.png') and ensure that only relevant events (image file uploads) invoke the Lambda function. While other options suggest using policies or intermediaries like SQS, they do not directly filter events based on file extensions, which is a key requirement here.

  • A. Incorrect.

    Incorrect. S3 Event Notifications cannot filter files within the Lambda function. Filtering must be configured in the S3 Event Notification itself.

  • B. Correct.

    Correct. S3 Event Notifications can be configured with prefix and suffix filters, allowing you to specify file extensions (e.g., '.jpg', '.png') so that only relevant events trigger the Lambda function.

  • C. Incorrect.

    Incorrect. S3 bucket policies control access to the bucket but cannot filter events based on file extensions.

  • D. Correct.

    Correct. S3 Event Notification filters can be set up directly to include specific suffixes such as '.jpg' and '.png', ensuring that only image files trigger the Lambda function.

  • E. Incorrect.

    Incorrect. Amazon SQS does not natively filter messages based on file types. While you can use SQS as an intermediary, this wouldn't directly filter file extensions.

Timed practice exam

Take a DVA-C02 practice test under exam conditions

65 questions in 130 minutes, drawn from this bank, with a score report and a per-question review when you finish.

Start timed exam