The module creates Azure Virtual Network with flexible number of subnets, and optionally creates Azure Bastion in the managed Virtual Network.
Once you have a Corewide Solutions Portal account, this one-time action will use your browser session to retrieve credentials:
shellterraform login solutions.corewide.com
Initialize mandatory providers:
Copy and paste into your Terraform configuration and insert the variables:
hclmodule "tf_azure_vnet" {
source = "solutions.corewide.com/azure/tf-azure-vnet/azurerm"
version = "~> 2.0.0"
# specify module inputs here or try one of the examples below
...
}
Initialize the setup:
shellterraform init
Corewide DevOps team strictly follows Semantic Versioning
Specification
to
provide our clients with products that have predictable upgrades between versions. We
recommend
pinning
patch versions of our modules using pessimistic
constraint operator (~>) to prevent breaking changes during upgrades.
To get new features during the upgrades (without breaking compatibility), use
~> 2.0 and run
terraform init -upgrade
For the safest setup, use strict pinning with version = "2.0.0"
|
Module
20% off
|
€510
|
| TOTAL | €510 |
The module creates Azure Virtual Network with flexible number of subnets, and optionally creates Azure Bastion in the managed Virtual Network.
All notable changes to this project are documented here.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
5.0(Last version compatible with the Azure Terraform provider version 4.0)
rules parameter for the subnets variable to manage network security group rules per subnet4.57constructed_ids output with predetermined IDs of the managed resources in accordance with Azure fully qualified resource ID pattern conventionsubnets variable validation rule to allow passing more than one correct service endpoint for a single subnet4.0(Last version compatible with the Azure Terraform provider version 3.0)
routes parameter to subnets variable to manage routes for subnets' route tablesBREAKING CHANGE: now all the managed resources follow Azure naming conventions and resource names aren't compatible with previous module versions. Upgrading to this version will result in a complete re-creation of the Virtual Network resources. For more details see the Upgrade Notes section
name_prefix variable to name_suffixv1.x to v2.xModule from v2.0 has changed naming model of managed resources in accordance with Azure naming conventions, so all resources of the module will be re-created. Also, there is re-named variable name_prefix to name_suffix. Update module inputs following the documentation, and apply changes.
v2.x to v3.xModule from v3.0 has changed Azure Terraform provider version, which isn't compatible with older versions. After the module version is upgraded, re-init the module to upgrade the provider version. Upgrade the Azure provider version at the project level:
hclterraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 4.0"
}
}
}
Upgrade project dependencies:
bashterraform init --upgrade
Update the declaration of the module according to the requirements and examples to match the designed configuration, then the configuration can be applied.
Apply the changes to make sure the state of the resources is up-to-date with the new provider version:
bashterraform apply
v3.x to v4.xModule from v4.0 has changed Azure Terraform provider version, which isn't compatible with older versions. After the module version is upgraded, re-init the module to upgrade the provider version. Upgrade the Azure provider version at the project level:
hclterraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 5.0"
}
}
}
Upgrade project dependencies:
bashterraform init --upgrade
Update the declaration of the module according to the requirements and examples to match the designed configuration, then the configuration can be applied.
Apply the changes to make sure the state of the resources is up-to-date with the new provider version:
bashterraform apply
Create Virtual Network with 2 Subnets packed in different configuration flavors:
hclresource "azurerm_resource_group" "foo" {
name = "foo"
location = "eastus"
}
module "vnet" {
source = "solutions.corewide.com/azure/tf-azure-vnet/azurerm"
version = "~> 2.0"
name_suffix = "bar"
resource_group_name = azurerm_resource_group.foo.name
region = azurerm_resource_group.foo.location
address_space = [
"10.0.0.0/16",
]
subnets = [
{
name_suffix = "baz"
addresses = [
"10.0.1.0/24",
]
},
{
name_suffix = "biz"
addresses = [
"10.0.2.0/24",
]
service_endpoints = [
"Microsoft.AzureCosmosDB",
]
},
{
name_suffix = "qux"
delegation = "Microsoft.AzureCosmosDB/clusters"
addresses = [
"10.0.3.0/24",
]
},
]
tags = {
Project = "foo"
}
}
Create Virtual Network only:
hclresource "azurerm_resource_group" "foo" {
name = "foo"
location = "eastus"
}
module "vnet" {
source = "solutions.corewide.com/azure/tf-azure-vnet/azurerm"
version = "~> 2.0"
name_suffix = "bar"
resource_group_name = azurerm_resource_group.foo.name
region = azurerm_resource_group.foo.location
address_space = [
"10.0.0.0/16",
]
tags = {
Project = "foo"
}
}
Create Virtual Network with 1 Subnet and Bastion Service:
hclresource "azurerm_resource_group" "foo" {
name = "foo"
location = "eastus"
}
module "vnet" {
source = "solutions.corewide.com/azure/tf-azure-vnet/azurerm"
version = "~> 2.0"
name_suffix = "bar"
resource_group_name = azurerm_resource_group.foo.name
region = azurerm_resource_group.foo.location
bastion_pool = "10.0.250.0/26"
address_space = [
"10.0.0.0/16",
]
subnets = [
{
name_suffix = "baz"
addresses = [
"10.0.1.0/26",
]
},
]
tags = {
Project = "foo"
}
}
| Variable | Description | Type | Default | Required | Sensitive |
|---|---|---|---|---|---|
address_space |
The list of IP pools for Virtual Network | list(string) |
yes | no | |
name_suffix |
Naming suffix for the resources created by the module | string |
yes | no | |
region |
Resource Group location where Virtual Network will be created | string |
yes | no | |
resource_group_name |
The Resource Group Name in which resources should be created | string |
yes | no | |
bastion_pool |
Create Azure Bastion within the VN if set. Will create a special Subnet with provisioned IP pool to setup Bastion service (at least /26 mask required) | string |
no | no | |
subnets |
A list of Virtual Network Subnets to create | list(object) |
[] |
no | no |
subnets[*].addresses |
List of IP Pools to assign to the Subnet (within the VN pools) | list(string) |
yes | no | |
subnets[*].delegation |
If set, will delegate this Subnet to the Service defined here | string |
no | no | |
subnets[*].enable_private_endpoints |
Enable or Disable network policies for the private link endpoint on the Subnet. Set to true if using Private Link Endpoints |
bool |
false |
no | no |
subnets[*].name_suffix |
The name suffix of the Subnet to create | string |
yes | no | |
subnets[*].service_endpoints |
If set, will allow the setup of listed Services endpoints within this Subnet for secure private communications. Additional configurations on the Service resources required | list(string) |
no | no | |
tags |
A map of tags to apply (where key is a tag name and value is a tag value) | map(any) |
{} |
no | no |
| Output | Description | Type | Sensitive |
|---|---|---|---|
bastion |
Contains attributes of azurerm_bastion_host.bastion resource | computed |
no |
network_security_groups |
The list of Network Security Groups associated to created Subnets. Passes attributes of azurerm_network_security_group.nsg resources | computed |
no |
route_tables |
The list of Route Tables associated to created Subnets. Passes attributes of azurerm_route_table.rt resources | computed |
no |
subnets |
The list of created Subnets within the Virtual Network. Passes attributes of azurerm_subnet.snet resources | computed |
no |
virtual_network |
Contains attributes of azurerm_virtual_network resource | resource |
no |
| Dependency | Version | Kind |
|---|---|---|
terraform |
>= 1.3 |
CLI |
hashicorp/azurerm |
~> 3.0 |
provider |