Trigger Fargate tasks from S3 with a Lambda container-selection function
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?
Community Votes
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)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
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 →