How does terraform use modules?

How does terraform use modules?

For example in the below link there is reference to a module?
source = “innovationnorway/virtual-network/azurerm” what is this path for?

Please explain.

There is also module in the upper right of the html page. All it says is to run terraform init. What is the comment to “# insert the 4 required variables here”? What are these 4 variables?

module “virtual-network” {
source = “innovationnorway/virtual-network/azurerm”
version = “1.0.0”

insert the 4 required variables here



resource "azurerm_resource_group" "example" {
  name     = "example-resources"
  location = "westeurope"

module "virtual_network" {
  source = "innovationnorway/virtual-network/azurerm"

  name = "example-network"

  resource_group_name =

  address_space = [""]

  subnets = [
      name           = "subnet-1"
      address_prefix = ""
      name           = "subnet-2"
      address_prefix = ""
      delegations    = ["Microsoft.ContainerInstance/containerGroups"]

The module source is flexible and can be used to mean one of:

  • Terraform Registry reference
  • relative / fully qualified path on local file system
  • git repository
  • http/https

The example you provded would be interpreted by Terraform as a registry module.
The module sources are described here.

In regards to the 4 required variables, the module you reference takes 6 total possible input variables, but 4 of them do not have a default value, so must be provided (are required) when you invoke the module. The input variables are documented on the Terraform Registry under the Inputs tab:

In addition to what @sl1pm4t shared, there’s some general background information on Terraform modules in the documentation section Modules. I think the content on that page should hopefully connect the dots a little; if you have any follow-on questions please do ask!