Back to portfolio
Case study · Infrastructure as code

Production-grade GKE with Terraform and a Shared VPC

Taking a hand-provisioned GKE estate to 100% infrastructure as code: a Shared VPC, private clusters, an 8-phase rollout and the guardrails that stop a stray destroy. Plus the open-source landing zones I built for GCP, AWS and Azure on the same pattern.

By Vitor Schiavo Updated October 2026 ~8 min read
Solution at a glanceSeparate shared networking from environment workloads.
Terraform modulesVersion reusable infrastructure
Shared VPCDefine subnets and boundaries
GKE environmentsProvision isolated workloads

Reusable Terraform modules provision network boundaries and GKE resources consistently.

Contribution at a glance

My responsibility
Modular Terraform, network boundaries and a phased GKE platform rollout.
Scope
Shared VPC and isolated environment infrastructure; public landing-zone examples are separate reusable code.
Collaboration & boundaries
I designed and implemented the infrastructure foundation described here; public examples generalize the pattern rather than expose employer configuration.
Outcome
Reusable environment provisioning and protected shared-network resources, delivered through a phased ownership transition.

Picture a GKE estate and the network under it, all provisioned by hand. No infrastructure as code, no consistent story across environments, and nothing stopping a stray terraform destroy from taking out the shared network. This is a write-up of rebuilding that into a Shared VPC, private clusters, a modular Terraform codebase, and an eight-phase rollout that never left the system half-managed.

Everything here is the technique, with no internal names or specifics. At the end I link the open-source landing zones I built for GCP, AWS and Azure, so you can read the actual code behind the same pattern.

The starting point

Clusters and network were created through the console and a monolithic, copy-pasted Terraform file. There was no reusable module, no per-environment strategy, and no prevent_destroy on the network. In other words, the one resource you cannot casually recreate, the VPC, was the least protected thing in the project.

The target architecture

The rollout, in eight phases

The point of phasing it was to never have a window where the network was half-managed. Each phase left the system in a working state.

The guardrail that matters most

A prevent_destroy lifecycle block on the VPC, subnets and Cloud NAT makes an accidental terraform destroy of the network fail instead of succeed. The network is the one thing you cannot casually recreate, so it is the one thing that should refuse to be deleted. It costs three lines and has saved real outages.

100%infrastructure as code
4GKE clusters, one pipeline
0public node IPs
3open-source landing zones

Results

The same pattern, as open source

The write-up above stays generic, so here is the same pattern as code you can actually read. I built a landing zone for each major cloud: a Terraform plus GitHub Actions setup for multi-environment Kubernetes, with the security defaults baked in (remote state, no secrets in the repo, least-privilege IAM, a prominent security notice in each README).

What I would tell someone starting this

Decisions and next steps

A retrospective view of the approach and its limits. The next improvement is a proposal, not a delivered result.

Alternative and rationale

A monolithic stack is quick to start; separating shared networking from environment workloads reduces destructive coupling.

Trade-off

Modules add interfaces and state boundaries that need ownership, versioning and safe migration.

What I would improve next

Next improvement: automate drift checks and validate recovery from each infrastructure state boundary.