darkraiden / terraform-module-azure-vnet

Terraform Module to Create Azure Virtual Networks and Subnets

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

terraform-module-azure-vnet

Terraform module to create a new Azure Virtual Network and its respective subnets.

Module Usage

resource "azurerm_resource_group" "this" {
    name     = "my-resource-group"
    location = "northeurope"
}

module "myvnet" {
    source = "github.com/darkraiden/terraform-module-azure-vnet"

    vnet_name      = "my-vnet"
    resource_group = azurerm_resource_group.this
    address_space  = ["10.0.0.0/24"]
    subnets        = [
        {
            name = "subnet1"
            address_prefixes = ["10.0.0.0/25"]
        },
        {
            name = "subnet1"
            address_prefixes = ["10.0.0.128/25"]
        }
    ]
}

Test Module

This module comes with a terratest test suite. Before running the tests, ensure you have the following:

  • Azure cli installed and configured
  • Write access to an Azure Subscription/Tenant
  • Go installed

To run the tests, execute the following command:

export TEST_AZURE_SUBSCRIPTION_ID=<your-subscription-id>
export TEST_AZURE_TENANT_ID=<your-tenant-id>

cd tests/
go test -v -timeout 30m -count 1 ./...

Requirements

Name Version
terraform >= 1.4.0
azurerm >= 3.40.0, <= 3.50.0

Providers

Name Version
azurerm >= 3.40.0, <= 3.50.0

Modules

No modules.

Resources

Name Type
azurerm_network_ddos_protection_plan.this resource
azurerm_subnet.this resource
azurerm_virtual_network.this resource

Inputs

Name Description Type Default Required
address_space The list of address space prefixes used by the Virtual Network. list(string) n/a yes
enable_ddos_protection_plan [Optional] Should a DDoS Protection Plan be associated with the Virtual Network? bool false no
location The location/region where the Virtual Network should exist. string null no
resource_group The Resource Group where the Virtual Network should exist.
object({
id = string
name = string
location = string
})
n/a yes
subnets [Optional] A list of subnets to be created within the Virtual Network.
list(object({
name = string
address_prefixes = list(string)
}))
[] no
vnet_name The name of the Virtual Network. string n/a yes

Outputs

Name Description
ddos_protection_plan_id The ID of the DDoS Protection Plan associated with the Virtual Network.
subnet_ids The list of subnet IDs associated with the Virtual Network.
vnet_address_space The list of address space prefixes used by the Virtual Network.
vnet_id The ID of the Virtual Network.
vnet_location The location of the Virtual Network. Defaults to the Resource Group's location if not set.
vnet_name The name of the Virtual Network.

About

Terraform Module to Create Azure Virtual Networks and Subnets

License:MIT License


Languages

Language:HCL 56.0%Language:Go 44.0%