Skip to content

Creates an Azure vnet with optional custom subnets. Highly flexible module that takes the same arguments as azurerm_virtual_network and azurerm_subnet definitions.

License

Notifications You must be signed in to change notification settings

cloudelementsca/terraform-azurerm-network

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

terraform-azurerm-network

Description

This module creates an Azure virtual network, and optional custom subnets, in an existing resource group and location that you specify. It's highly adjustable and takes the same input variables as azurerm_virtual_network and azurerm_subnet resource definitions have attributes. All attributes for the vnet and subnets are optional. The vnet output variables contain all the information for the vnet and subnets.

Using the Module

See the examples/ folders on how to use the module.

Terraform Registry

module "network" {
  source = "cloudelementsca/terraform-azurerm-network"

  resource_group_name = azurerm_resource_group.network_rg.name
  location            = azurerm_resource_group.network_rg.location
}

GitHub

module "network" {
  source = "github.com/cloudelementsca/terraform-azurerm-network"

  resource_group_name = azurerm_resource_group.network_rg.name
  location            = azurerm_resource_group.network_rg.location
}

Requirements

The following requirements are needed by this module:

Providers

The following providers are used by this module:

Modules

No modules.

Resources

The following resources are used by this module:

Required Inputs

The following input variables are required:

Description: Location for all resources.

Type: string

Description: Name of existing resource group that will contain the vnet.

Type: string

Optional Inputs

The following input variables are optional (have default values):

Description: Vnet definition.

Type:

object({
    address_space = list(string)
    subnets = optional(map(object({
      address_prefixes = optional(list(string))
      name             = optional(string)
      service_delegations = optional(map(object({
        name    = string
        actions = list(string)
      })), {})
      private_endpoint_network_policies_enabled     = optional(bool)
      private_link_service_network_policies_enabled = optional(bool)
      service_endpoints                             = optional(list(string))
      service_endpoint_policy_ids                   = optional(list(string))
    })), { subnet1 = {} })
    name          = optional(string)
    dns_servers   = optional(list(string), [])
    bgp_community = optional(string)
    ddos_protection_plan = optional(object({
      id     = string
      enable = bool
    }))
    edge_zone               = optional(string)
    flow_timeout_in_minutes = optional(number)
  })

Default:

{
  "address_space": [
    "10.0.0.0/8"
  ]
}

Description: Tags for all resources.

Type: map(string)

Default:

{
  "environment": "dev"
}

Outputs

The following outputs are exported:

Description: All subnets info.

Description: All vnet info.

Sample Output

subnets = {
  "aci-subnet" = {
    "address_prefixes" = tolist([
      "10.19.2.0/24",
    ])
    "delegation" = tolist([
      {
        "name" = "aci_delegation"
        "service_delegation" = tolist([
          {
            "actions" = tolist([
              "Microsoft.Network/virtualNetworks/subnets/action",
            ])
            "name" = "Microsoft.ContainerInstance/containerGroups"
          },
        ])
      },
    ])
    "enforce_private_link_endpoint_network_policies" = false
    "enforce_private_link_service_network_policies" = false
    "id" = "/subscriptions/***/resourceGroups/vnet-rg/providers/Microsoft.Network/virtualNetworks/vnet-vwtrnqh0/subnets/subnet-6gf6cbed"
    "name" = "subnet-6gf6cbed"
    "private_endpoint_network_policies_enabled" = true
    "private_link_service_network_policies_enabled" = true
    "resource_group_name" = "vnet-rg"
    "service_endpoint_policy_ids" = toset(null) /* of string */
    "service_endpoints" = toset(null) /* of string */
    "timeouts" = null /* object */
    "virtual_network_name" = "vnet-vwtrnqh0"
  }

vnet = {
  "address_space" = tolist([
    "10.19.0.0/16",
  ])
  "bgp_community" = ""
  "ddos_protection_plan" = tolist([])
  "dns_servers" = tolist([])
  "edge_zone" = ""
  "flow_timeout_in_minutes" = 0
  "guid" = "3e7b1ade-20f4-4957-9c61-8074dfac2775"
  "id" = "/subscriptions/***/resourceGroups/vnet-rg/providers/Microsoft.Network/virtualNetworks/vnet-vwtrnqh0"
  "location" = "canadacentral"
  "name" = "vnet-vwtrnqh0"
  "resource_group_name" = "vnet-rg"
  "subnet" = toset([])
  "tags" = tomap({
    "environment" = "dev"
  })
  "timeouts" = null /* object */
}

About

Creates an Azure vnet with optional custom subnets. Highly flexible module that takes the same arguments as azurerm_virtual_network and azurerm_subnet definitions.

Topics

Resources

License

Stars

Watchers

Forks