Menu

1 / 2

Building a Reusable VPC, Subnets, and Firewall Rules Module

DEV Community·Abraham Naiborhu·6 months ago
#gNm434wA
#root#child#terraform#verify#module
Reading 0:00
15s threshold

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…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.