This Terraform module deploys a Virtual Network in Azure with a subnet and NSG or a set of subnets passed in as input parameters.
resource "azurerm_resource_group" "test" {
name = "my-resources"
location = "West Europe"
}
module "network" {
source = "Azure/network/azurerm"
resource_group_name = azurerm_resource_group.test.name
address_space = "10.0.0.0/16"
subnets = {
subnet1 = {
address_prefixes = ["10.0.1.0/24"]
nsg = false
}
subnet2 = {
address_prefixes = ["10.0.2.0/24"]
}
}
tags = {
environment = "dev"
costcenter = "it"
}
}
resource "azurerm_resource_group" "test" {
name = "my-resources"
location = "West Europe"
}
module "network" {
source = "Azure/network/azurerm"
resource_group_name = azurerm_resource_group.test.name
address_space = "10.0.0.0/16"
subnets = {}
tags = {
environment = "dev"
costcenter = "it"
}
}
We provide 2 ways to build, run, and test the module on a local development machine. Native (Mac/Linux) or Docker.
We provide simple script to quickly set up module development environment:
$ curl -sSL https://raw.githubusercontent.com/Azure/terramodtest/master/tool/env_setup.sh | sudo bash
Then simply run it in local shell:
$ cd $GOPATH/src/{directory_name}/
$ bundle install
$ rake build
$ rake full
We provide a Dockerfile to build a new image based FROM
the microsoft/terraform-test
Docker hub image which adds additional tools / packages specific for this module (see Custom Image section). Alternatively use only the microsoft/terraform-test
Docker hub image by using these instructions.
This builds the custom image:
$ docker build --build-arg BUILD_ARM_SUBSCRIPTION_ID=$ARM_SUBSCRIPTION_ID --build-arg BUILD_ARM_CLIENT_ID=$ARM_CLIENT_ID --build-arg BUILD_ARM_CLIENT_SECRET=$ARM_CLIENT_SECRET --build-arg BUILD_ARM_TENANT_ID=$ARM_TENANT_ID -t azure-network .
This runs the build and unit tests:
$ docker run --rm azure-network /bin/bash -c "bundle install && rake build"
This runs the end to end tests:
$ docker run --rm azure-network /bin/bash -c "bundle install && rake e2e"
This runs the full tests:
$ docker run --rm azure-network /bin/bash -c "bundle install && rake full"
No requirements.
Name | Version |
---|---|
azurerm | n/a |
Name | Description | Type | Default | Required |
---|---|---|---|---|
address_space | The address space that is used by the virtual network. | list(string) |
[ |
no |
dns_servers | The DNS servers to be used with vNet. | list |
[] |
no |
name | Name of the vnet to create | string |
"acctvnet" |
no |
resource_group_name | Name of the resource group to be imported. | any |
n/a | yes |
subnets | If no values specified, this defaults to creating two subnets | map |
{ |
no |
tags | The tags to associate with your network and subnets. | map(string) |
{ |
no |
Name | Description |
---|---|
network_security_groups | The network security groups objects created by this module |
subnets | The subnets created by this module |
vnet | The entire azurerm_virtual_network resource |
vnet_address_space | The address space of the newly created vNet |
vnet_id | The id of the newly created vNet |
vnet_location | The location of the newly created vNet |
vnet_name | The Name of the newly created vNet |
Originally created by Eugene Chuvyrov Updated by Alex Bevan