Learn how to use AWS Lambda destinations to implement a fallback mechanism for profile picture processing. Compare different solutions and find out the best one with the least development effort.
Table of Contents
Question
A developer is using an AWS Lambda function to generate avatars for profile pictures that are uploaded to an Amazon S3 bucket. The Lambda function is automatically invoked for profile pictures that are saved under the /original/ S3 prefix. The developer notices that some pictures cause the Lambda function to time out. The developer wants to implement a fallback mechanism by using another Lambda function that resizes the profile picture.
Which solution will meet these requirements with the LEAST development effort?
A. Set the image resize Lambda function as a destination of the avatar generator Lambda function for the events that fail processing.
B. Create an Amazon Simple Queue Service (Amazon SQS) queue. Set the SQS queue as a destination with an on failure condition for the avatar generator Lambda function. Configure the image resize Lambda function to poll from the SQS queue.
C. Create an AWS Step Functions state machine that invokes the avatar generator Lambda function and uses the image resize Lambda function as a fallback. Create an Amazon EventBridge rule that matches events from the S3 bucket to invoke the state machine.
D. Create an Amazon Simple Notification Service (Amazon SNS) topic. Set the SNS topic as a destination with an on failure condition for the avatar generator Lambda function. Subscribe the image resize Lambda function to the SNS topic.
Answer
A. Set the image resize Lambda function as a destination of the avatar generator Lambda function for the events that fail processing.
Explanation
The correct answer is A. Set the image resize Lambda function as a destination of the avatar generator Lambda function for the events that fail processing.
Here is an explanation of why this solution will meet the requirements with the least development effort:
- The problem is that the developer is using a Lambda function to generate avatars for profile pictures that are uploaded to an S3 bucket, but some pictures cause the Lambda function to time out. The developer wants to implement a fallback mechanism by using another Lambda function that resizes the profile picture.
- To solve this problem, the developer needs to use a feature of Lambda that allows setting another function as a destination for events that fail processing. A destination is a resource that receives the execution results of a Lambda function, such as another Lambda function, an SNS topic, an SQS queue, or an EventBridge event bus. A destination can be configured with an on success or on failure condition, which determines when the destination receives the execution results.
- The solution that meets the requirements with the least development effort is to set the image resize Lambda function as a destination of the avatar generator Lambda function for the events that fail processing. This way, whenever the avatar generator Lambda function times out or encounters an error, it will send the event details to the image resize Lambda function, which will then resize the profile picture and save it to the S3 bucket. This solution does not require any additional resources or services, and it can be easily configured using the AWS Management Console, AWS CLI, or AWS SDKs.
- This solution will meet the requirements because it will provide a simple and reliable fallback mechanism for handling profile pictures that cause the avatar generator Lambda function to time out. It will also reduce the development effort and complexity of the application.
Therefore, option A is the correct solution that will meet the requirements with the least development effort. Option B is incorrect because it will require creating and managing an SQS queue, which will add more resources and costs to the application. Option C is incorrect because it will require creating and managing a Step Functions state machine and an EventBridge rule, which will add more services and complexity to the application. Option D is incorrect because it will require creating and managing an SNS topic, which will add more resources and costs to the application.
The latest AWS Certified Developer – Associate DVA-C02 certification actual real practice exam question and answer (Q&A) dumps are available free, which are helpful for you to pass the AWS Certified Developer – Associate DVA-C02 exam and earn AWS Certified Developer – Associate DVA-C02 certification.