Laravel Projects Migration to AWS ECS

Laravel Migration to AWS
In april-jun 2024, I helped a client with the migration of several Laravel projects to AWS.
The final solution encompassed 3 projects: two websites and a web based management application.
For each application, a separate staging and production environment was set up.
ECS versus EKS versus Vapor (lambda serverless)
The solution architecture was around ECS's, AWS's proprietary container orchestration service.
It's feature set (such as autoscaling, isolation) was sufficient for current and future requirements, and does not incur the overhead by K8s/EKS for this kind of projects.
Additionally, I was happy to be given the task to evaluate Laravel Vapor for the applications. Vapor is a fully managed service that deploys laravel applications serverless using lambda functions. While this seemed a feasible solution at first, concerns were raised in particular regarding security, costs and speed. Stress and load tests for speed led to the definitive rejection of Laravel Vapor for these applications.
Deliverables:
- CD pipelines for each application and environment
- CodeBuild project to build the application, asset
- Application version artifacts stored as multi-architecture docker images in ECR
- Staging and production ECS clusters to deploy the applications in
- Configuration of autoscaling, concurrency and spot/non spot through CloudFormation
- CloudFormation templates to manage the services, task definitions and attachment to a load balancer
- CloudFront in front of the load balancer for enhanced speed and attaching a WAF when needed
- An ipv6 dualstack VPC, accessible only through a jump/bastion host or AWS Cloud Console
- Setup of data stores: AWS RDS (MariaDB), Redis and S3
- Database migration and application migration support / modifying the application to be cloud native.
- Add additional (pdf generating) services in ECS as a microservice exposed through service discovery
- TLS (https) certificate management through AWS ACM
By using CloudFormation for components, I was able to set up the second and third environment consistently and quickly.
Legacy application
For the migration plan, a requirement was to deploy an existing management application into AWS with minimal changes. After everything is migrated to AWS, a brand new laravel application would be written and the legacy application would be deprecated.
For this application a single ec2 instance was set up for each environment. The main challenge was the asset management, the migrated applications use S3 for assets, while the old architecture used a wild system of symlinks on a single host.
As this release is only temporary, I choose to mount s3 buckets with s3fuse on the host, and then mount this in the docker containers. So the legacy application just works with almost zero modifications
This is working perfectly.
Vaardigheden
- AWS CodePipeline
- AWS ECS / Fargate
- AWS ECR
- CloudFront
- AWS S3
- AWS CloudFormation
- AWS CloudWatch
- Ansible