Some of the company’s applications recently moved from Rancher to Fargate, which is understandable as the cloud resource and traffic will be very intensive only during a certain period (HSC exam), hence AWS serverless with Fargate can be a better option for such business mode so rest of the year without exam we can save cost significantly.
Hosting our blog on Fargate? Why not!
In the past, I used to try different methods to host this blog:
Here I will use AWS Fargate, together with AWS ECR, Docker, Terraform and Github Action workflow to move this blog to AWS serverless compute for containers.
Terraform Provisioning
Github Action Workflow fo CICD
1.First we need to create Github Secret to contain dockerhub and aws credentials and some other vars:
2.Then define the workflow to create /.github/workflows/zackblog-fargate.yaml, in this configure Github runner, it will :
Log in to Amazon ECR
Build and push Docker Image to the ECR repository
Deploy to ECS by updating the ECS service to use the new image by forcing a new deployment
Conclusion
Now we have a seamless incurvature as a code together with CICD pipeline to ensure that the “Zack’s Blog” can be moved to AWS serverless container service Fargate, every time I update the blog by committing changes to “zack-gitops-project” editing branch, a new Docker image will be built, pushed to ECR, and the AWS Fargate service is automatically updated.