Trigger Fargate tasks from S3 with a Lambda container-selection function

Answer Correct answer: C — Move uploads to S3, use a Lambda function to pick and start the Fargate task, and invoke it from an S3 object-created notification.

A company hosts a data-processing application on Amazon EC2 instances. The application polls an Amazon Elastic File System (Amazon EFS) file system for newly uploaded files. When a new file is detected, the application extracts data from the file and runs logic to select a Docker container image to process the file. The application starts the appropriate container image and passes the file location as a parameter. The data processing that the container performs can take up to 2 hours. When the processing is complete, the code that runs inside the container writes the file back to Amazon EFS and exits. The company needs to refactor the application to eliminate the EC2 instances that are running the containers. Which solution will meet these requirements?

  1. Create an Amazon Elastic Container Service (Amazon ECS) cluster. Configure the processing to run as AWS Fargate tasks. Extract the container selection logic to run as an Amazon EventBridge rule that starts the appropriate Fargate task. Configure the EventBridge rule to run when files are added to the EFS file system.
  2. Create an Amazon Elastic Container Service (Amazon ECS) cluster. Configure the processing to run as AWS Fargate tasks. Update and containerize the container selection logic to run as a Fargate service that starts the appropriate Fargate task. Configure an EFS event notification to invoke the Fargate service when files are added to the EFS file system.
  3. Create an Amazon Elastic Container Service (Amazon ECS) cluster. Configure the processing to run as AWS Fargate tasks. Extract the container selection logic to run as an AWS Lambda function that starts the appropriate Fargate task. Migrate the storage of file uploads to an Amazon S3 bucket. Update the processing code to use Amazon S3. Configure an S3 event notification to invoke the Lambda function when objects are created. Correct Answer
  4. Create AWS Lambda container images for the processing. Configure Lambda functions to use the container images. Extract the container selection logic to run as a decision Lambda function that invokes the appropriate Lambda processing function. Migrate the storage of file uploads to an Amazon S3 bucket. Update the processing code to use Amazon S3. Configure an S3 event notification to invoke the decision Lambda function when objects are created.

Community Votes

C
100%

100% of anonymous learners picked answer C. Votes are pick records left by other test-takers — they are not the verified answer.

Community Insight

EFS does not emit events that EventBridge rules can match, so the file-upload trigger has to move to S3 object-created notifications, and because a two-hour job exceeds the Lambda limit the execution itself must stay in ECS Fargate tasks while Lambda only makes the routing decision.

An application on EC2 polls an EFS file system for new files, picks a Docker image per file, and runs it as a container that can take up to two hours before writing results back to EFS. The company wants to remove the EC2 instances that run the containers while keeping the per-file container selection logic.

Trying to trigger on EFS directly. EFS has no event notification capability analogous to an S3 object-created notification, so neither an EventBridge rule nor an EFS event notification can start the processing when a file appears, which rules out both the EFS-based options.

Community Discussion (5 comments)

0b43291 👍 2 Selected: C
By combining Amazon ECS with Fargate tasks, AWS Lambda for the container selection logic, and Amazon S3 for event-driven processing, Option C provides a serverless and scalable solution that meets the requirements while minimizing the need for EC2 instances and leveraging the strengths of each AWS service. While this solution requires migrating the file storage from Amazon EFS to Amazon S3, it addresses the requirement of eliminating EC2 instances by leveraging AWS Fargate for the processing tasks and AWS Lambda for the container selection logic. Additionally, it utilizes the event notification capabilities of Amazon S3 to trigger the Lambda function when new files are uploaded. The other options are either not feasible due to the limitations of Amazon EFS (Options A and B) or introduce additional constraints by using AWS Lambda for the long-running data processing tasks (Option D).
mkgiz 👍 1 Selected: C
EFS event notification to invoke the Fargate
mark_232323 👍 3 Selected: C
EFS event notification to invoke the Fargate --> EFS don't have event notification like s3
vip2 👍 3 Selected: C
C EventBridge can not monitor EFS event directly, not A
kupo777 👍 3
C EFS cannot notify events and Lambda cannot do container execution for 2 hours.

Comments & Corrections

No comments yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

Submitted for moderation before publishing. Keep it helpful and respectful.

Expert Analysis

Why the Answer Is Correct

The processing takes up to two hours, which exceeds the maximum duration of a Lambda function, so the containerised work must run as Amazon ECS Fargate tasks rather than in Lambda. That leaves the selection logic, which is a fast decision, as a Lambda function that inspects the new file and starts the appropriate Fargate task. For the trigger, the storage moves to Amazon S3 because S3 emits an object-created event notification that can invoke the Lambda function directly, and the processing code is updated to read and write S3 instead of EFS. This removes the EC2 instances entirely, since Fargate runs the tasks and Lambda runs the decision, both serverless.

Why the Other Options Are Wrong

A: An EventBridge rule cannot be configured to run when files are added to an EFS file system, because EFS does not publish events that EventBridge patterns can match, so the trigger would never fire. B: EFS likewise has no event notification feature, so the proposed EFS event notification to invoke the Fargate service does not exist, and a Fargate service is a long-running service rather than a per-file decision maker. D: Lambda container images are subject to the same maximum execution duration as any Lambda function, so a processing job that can take two hours cannot run in Lambda, which makes this option unable to meet the processing requirement.

Community Comment Notes

The community voted 100 to 0 for C, and the top comments identified the decisive constraint from two directions. One noted that EventBridge cannot monitor EFS events, which eliminates A, and another observed that EFS has no event notification like S3, which eliminates B. A further commenter added the other half of the reason, that Lambda cannot perform two-hour container execution, which rules out D.

Official Reference

Related Analysis

Practice All SAP-C02 Questions

Access 85 questions with complete answers and detailed explanations.

View Full SAP-C02 Practice Test →

← Back to SAP-C02 Study Guide