FAN - Infrastructure as Code Evaluation Exercise #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Architecture overview
This Terraform project provisions a AWS VPC in two Availability Zones (AZs) for fault tolerance and high availability.
It creates a Multi-AZ VPC with public/private subnets, per-AZ NAT Gateways, VPC Flow Logs, and deploys an ECS Fargate service connected to a private ECR repository behind an Application Load Balancer (ALB).
Core Components
1. VPC
10.0.0.0/162. Subnets (Multi-AZ)
Public Subnets (x2):
10.0.0.0/20,10.0.16.0/20)Private Subnets (x2):
10.0.32.0/20,10.0.48.0/20)3. Internet Gateway (IGW)
4. NAT Gateways (per AZ)
5. Route Tables
6. VPC Endpoints (optional)
7. VPC Flow Logs → CloudWatch
/vpc/<project>/flow-logs8. ECS Fargate Cluster & Tasks
9. Application Load Balancer (ALB)
Security Considerations
Deployment Steps
From the
webserverdirectory, run the following commands to build the Docker image. Replace the<app> and <region>with the correct values.aws ecr get-login-password --region
| docker login --username AWS --password-stdin .dkr.ecr..amazonaws.com
docker build -t .
docker tag :latest .dkr.ecr..amazonaws.com/:v1
docker push .dkr.ecr..amazonaws.com/:v1
Update container image name in terraform.tfvars file with the newly built container and save file.
From the
terraformdirectory, run the following commands to initialize and deploy VPC and ECS services: