In the previous Terraform labs, I created Google Cloud resources directly from the root configuration.
That worked, but the structure was still quite simple.
Every resource was defined directly inside the main Terraform configuration. For a small lab, that is fine. But as the infrastructure grows, putting everything in one root configuration can become harder to maintain.
So in this lab, I started learning Terraform modules.
The goal is to turn the previous VPC and subnet configuration into a reusable local module.
But instead of only creating one VPC and one subnet, I made the lab slightly more practical by creating:
one custom VPC network
two subnets
two firewall rules
reusable module inputs
module outputs
remote state using Google Cloud Storage
What is a Terraform Module?
A Terraform module is a collection of Terraform configuration files that are managed together.
In simple terms, a module is like a reusable infrastructure component.
For this lab, I created a local module…