This repository contains my Terraform configuration for deploying a load-balanced web environment on Google Cloud. The setup is modularized for better maintainability and uses a Managed Instance Group (MIG) to handle scaling.
What's inside? Network: Custom VPC and subnet based in europe-west10.
Compute: An instance template using Debian 11. It includes a startup script that handles apt locks and installs Apache automatically.
Scaling: A Managed Instance Group (MIG) that keeps 2 instances running.
Traffic: An External HTTP Load Balancer acting as the single entry point.
Security: Specific firewall rules for SSH, HTTP, and the required Google Health Check IP ranges.
Project Structure Instead of a single main.tf, I've split the resources to make it easier to navigate:
apis.tf: Enables Compute Engine services.
network.tf: VPC, subnets, and firewall rules.
template_instance.tf: VM configuration and startup scripts.
group_manager.tf: MIG setup.
load_balancer_bac.tf: Backend services, health checks, and forwarding rules.
provider.tf & variables.tf: GCP project authentication and environment settings.