Menu

1 / 2

Creating a VM from Network Module Outputs

DEV Community·Abraham Naiborhu·6 months ago
#Dg7O3I0j
#terraform#firewall#verify#module#enter
Reading 0:00
15s threshold

In the previous lab, I created a reusable Terraform module for Google Cloud networking.

That module created:

a custom VPC network

multiple subnets

firewall rules

outputs for network, subnet, and firewall information

That was already an improvement from writing every resource directly in the root configuration.

However, the network module was still isolated. It created network resources, but nothing else was consuming those outputs yet.

So in this lab, I wanted to take the next logical step:

Create a Compute Engine VM that uses the subnet output from the network module.

At first, I considered creating the VM directly in the root module. But then I changed the format and added a second module:

modules/gcp-vm

Enter fullscreen mode

Exit fullscreen mode

So now the lab has two child modules:

modules/gcp-network modules/gcp-vm

Enter fullscreen mode

Exit fullscreen mode

The purpose of this lab is to understand module composition.

The main idea is:

The network module creates the network.…

Continue reading — create a free account

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