Building an Amazon ECS resource with Fargate using Terraform
Journey: 📊 Community Builder 📊
Subject matter: Building on AWS
Another project build! It won’t always be as regular as this but I have momentum currently!
In this article, we build a VPC and create an Amazon ECS using Fargate. Within the 6 Pillars of the AWS Well-Architected Framework, Operational Excellence will be achieved by using Terraform to deliver an Infrastructure as Code pipeline.
Once the environment comes online, multiple container instances will be running in an auto-scaling configuration, communicating via a NAT gateway in a public subnet, while the ECS is residing in a private subnet. Access is granted to the ECS via a load balancer connected to an Internet Gateway.
Finally, we have CloudWatch delivering health checks, and logs and communicating with the auto-scaling boundaries.
Credit: This architecture was created using a fantastic walkthrough from Samuel Olayinka on Medium.
Please see the article: Here
What did I use to build this environment?
- Visual Studio Code platform
- Terraform
- AWS CLI
- Amazon ECS
- AWS Fargate
- Amazon CloudWatch
- Amazon VPC
- Multiple AZs
- Application Load Balancer
- Auto Scaling
- Public and Private subnets
- Security Groups
- Internet Gateway
- NAT Gateway
How did it look?
I initially created the project in eu-west-2 before destroying it and recreating it in us-east-1 to check out the build times between the two, which were negligible.
Some of the highlights…
The VPC builds:
Target groups online, using HTTP on port 80.
In a prod environment, this would have been HTTPS on port 443.
The ALB came online:
The environment is online!
Once I had built the environment, I was able to successfully visit my public Internet-facing ALB, and when refreshing the page, I could see my ALB redistributing against one of the three available ECS clusters.
CloudWatch was also monitoring and providing me with data.
Then… time for IaC destruction!!
Destruction complete!
My interpretation of the architecture:
I hope you have enjoyed the article, I enjoyed the build!