The Lambda ECS Template is a comprehensive solution for building scalable server architectures on AWS. This template repository defines an architecture that allows for the execution of long-running tasks using AWS Lambda and Amazon ECS (Elastic Container Service). By leveraging Lambda to trigger ECS tasks, this architecture enables tasks to run for hours on end, processing input from an S3 bucket and providing output back to the bucket upon completion.
The template includes Python code that allows Lambda functions to start ECS tasks, enabling the execution of long-running computations or tasks that exceed the 15-minute time limit imposed on traditional Lambda functions.
The architecture seamlessly integrates with Amazon S3, allowing ECS tasks to consume input files from S3 buckets and store output files back to the bucket upon completion. This facilitates efficient data transfer and storage management.
An API endpoint, specified through API Gateway, triggers the Lambda function, allowing users to initiate ECS tasks by sending HTTP requests to the endpoint. Users can specify input files to be processed by the ECS task, enabling flexible and customizable task execution.
The Python code follows the MVP (Model-View-Presenter) pattern, ensuring a clean and modular codebase that is easy to understand and maintain. Additionally, Python's unittest framework is utilized to achieve comprehensive test coverage, ensuring the reliability and stability of the code.
Origin verification is implemented to prevent malicious attempts at triggering the API endpoint, enhancing the security of the system. This helps safeguard against unauthorized access and potential security threats.
The template utilizes Docker to package the Python code, enabling easy deployment and management of containerized applications. Docker containers ensure consistency and portability across different environments, simplifying the deployment process.
Terraform is used to define and provision the necessary AWS resources, including Lambda functions, ECS clusters, API Gateway endpoints, and IAM roles. This enables the infrastructure to be managed as code, facilitating reproducibility and scalability.
GitHub Actions is leveraged for continuous integration and deployment, automating the build, test, and deployment processes. This streamlines development workflows and ensures that changes are deployed quickly and reliably.
The Lambda ECS Template was initially developed to address the need for executing long-running tasks at BYU's Record Linking Lab while keeping costs low. Traditional server solutions or EC2 instances were not feasible due to cost constraints, and the 15-minute time limit imposed on Lambda was insufficient for the required computations. Recognizing the potential for this architecture to solve similar problems across various applications, the template was built to provide a reusable foundation for future projects within the lab.
The Lambda ECS Template has already saved thousands of dollars in cloud computing costs and hundreds of man-hours by providing a scalable and cost-effective solution for executing long-running tasks on AWS. By standardizing the architecture and providing a reusable template, it has streamlined the development process and enabled teams to focus on building applications rather than worrying about infrastructure complexities. Moving forward, the template will continue to save time, money, and effort in building and deploying future applications, driving efficiency and innovation within the organization.
This template reduces project completion time, saves developer resources, and is cost efficient for running code in the cloud.
This is used by research labs at Brigham Young University.
Python, GitHub Actions, Docker, Terraform, Amazon Web Services, and Git were used to develop AWS Lambda ECS Template.